Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • When users who do not have app installed on their device are being redirected to App Web site

  • Users who DO have app installed are still redirected to App website but with the message at the bottom asking if they wish to open installed app instead.

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:

  • Set that the App is iOS and it is native.
  • Enabled deep linking and provided valid App store id.
  • Did NOT configure a web platform for it. I used to have it before but then removed it and saved changes.

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!

like image 909
InterestedDev Avatar asked Nov 01 '22 23:11

InterestedDev


1 Answers

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)

like image 122
primulaveris Avatar answered Nov 15 '22 06:11

primulaveris