Reputation:
How can I implement deep linking in new Facebook SDK in ios?
Upvotes: 0
Views: 400
Reputation: 1162
To deep link on Facebook, you'll need to use their App Links metatags on your website. The most confusing thing about Facebook’s App Links is that they are not actually links, they are metatags that go on your website. For example, here's how IMDB would add App Links to their movie site for The Rock:
<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
...
<meta property="al:ios:app_store_id" content="342792525" />
<meta property="al:ios:url" content="imdb://title/tt0117500" />
<meta property="al:ios:app_name" content="IMDb Movies & TV" />
<meta property="al:android:package" content="com.imdb.mobile" />
<meta property="al:android:url" content="imdb://title/tt0117500" />
<meta property="al:android:app_name" content="IMDb Movies & TV" />
...
</head>
...
</html>
You can see that their deep linking URI and path are imdb://title/tt0117500
and they have to specify it on their site so that the Facebook robot can scrape it.
Once the metatags are on the site, when the link is posted to Facebook's feed, they will open the app directly if it's installed by calling the URI specified in the metatags. Then, in your app's App Delegate, you can receive the URI specified in the openUrl
method like so:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSLog(@"opened app from URL %@", [url description]);
return YES;
}
You can parse the URL in that method and open the View Controller that will display the appropriate data associated with the URL.
Upvotes: 1