InterestedDev
InterestedDev

Reputation: 588

Facebook Linking to your app from news feed does not work properly

My app allows users to share some content to their Facebook news feed. The expected and wanted behaviour is this:

WANTED behaviour: - When their friends who do not have app installed tap on shared content they are redirected to App Store so they can download the app. - When users who DO have app installed tap on shared content they are supposed to be redirected to the App installed on device...

The way it works for me now is this:

Faecbook does explain this on their page https://developers.facebook.com/docs/ios/share#linking with this picture: https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.2178-6/10173495_549418608510092_1399488908_n.png

but I cannot figure out what they mean by "Mobile only: No web content" and how to fix this problem and make my app behave as WANTED. On Facebook in my facebook app settings I did:

Why would it still redirect users who do not have app installed to a website rather than App store? and for those users who have app installed why does it still open website?

Thank you for your help!

Upvotes: 5

Views: 1637

Answers (2)

primulaveris
primulaveris

Reputation: 986

The process for implementing a deep link in a newsfeed story is quite convoluted and requires several steps. First of all you need to create an App Link. There is some explanation here https://developers.facebook.com/docs/applinks/hosting-api

You need an access token which consists of "your_app_Id|your_app_secret" - you get these values from your Facebook app settings.

  1. Add a URL scheme to your app e.g. MyApp://fbLink
  2. Create an App LInk and get the App Link ID. Open up a Terminal window (on MAC) and input the following:

    curl https://graph.facebook.com/app/app_link_hosts -F access_token=“your_app_Id|your_app_secret" -F name="name" -F ios=' [ { "url" : "MyApp://fbLink", "app_store_id" : 1234567, "app_name" : "MyApp", }, ]' -F web=' { "should_fallback" : false, }'

The response is your app link ID e.g.

{"id":"1234567890"}
  1. The next step is to retrieve the canonical URL which you can use in your code, using the app link ID you got in step 2.

    curl -G https://graph.facebook.com/1234567890 -d access_token=“your_app_Id|your_app_secret" -d fields=canonical_url -d pretty=true

response (e.g.)

{
  "canonical_url": "https://fb.me/1234567890",
  "id": "1234567890"
}
  1. Post the news story in your code. Add a query with whatever fields you need. In this case, it's a userId but it can be anything you want.

    NSString *linkURL = [NSString stringWithFormat: @"https://fb.me/1234567890?brag=%li", (long)userId]; NSDictionary *params = @{ @"name" : NSLocalizedString(@"I'm playing MyApp!",nil), @"caption":NSLocalizedString( @"Try to beat me!", nil), @"description" :NSLocalizedString( @"My Score is x", nil), @"link" : linkURL };

  2. Process incoming link in your App Delegate. Search for query contains @"brag" extract the query and process the parameter(s)

Upvotes: 2

insic
insic

Reputation: 121

From the facebook documentation page.

If your app doesn't have web pages, you can use Facebook's App Links Hosting API to host your App Links. This scenario is common if you have a mobile-only app.

Upvotes: 0

Related Questions