1

I am trying to implement app link for Android. And my steps are : 1. Created facebook app and using that app id creating session to implement further api calls 2. To create applink object in android my api call is

new Request(
                Session.getActiveSession(),
                "app/app_link_hosts",
                null,
                HttpMethod.GET,
                new Request.Callback() {
                    public void onCompleted(Response response) {
                        try {

                            JSONObject obj = new JSONObject(response.getRawResponse());
//                            
                            Log.d("My App", obj.toString());

                        } catch (Throwable t) {
                            Log.e("My App", "Could not parse malformed JSON: \"" + response.getRawResponse() + "\"");
                        }

                    }
                }
        ).executeAsync();

but i am getting empty response. Plz correct me if i am wrong. Thanks in advance

1 Answers1

0
  1. You're using the GET method, which gets an app link url that was already created using the API, but will not create new ones.

  2. You can't create them from mobile devices since they require an app access token (not a user access token). If you look at the "Publishing" section of the documentation, you'll see that there's no Android or iOS code snippets.

  3. For detailed instructions on how to create an app link hosting url (from the command line, or server side), follow the steps here: https://developers.facebook.com/docs/applinks/hosting-api

Ming Li
  • 15,672
  • 3
  • 37
  • 35
  • 2
    Hi Ming, I'm trying to so something similar to the person who asked this question and I'm a little bit disappointed that I cannot create app links from android. On the page: https://developers.facebook.com/docs/applinks/android it talks about engaging user experience for android users and even gives an example: For example, if I see a story on my Facebook feed about completing this share tutorial and I tap on it, I will expect to be redirected to a view in your app that features this tutorial and not to your app's main activity. How can I implement this without creating app links on android? – Simon May 09 '15 at 19:49
  • You can still create deeplinks using a single web url. We talk about this in the App Links talk in the latest F8 conference, and we will soon have a sample that demonstrates this. https://developers.facebooklive.com/videos/568/great-experiences-with-app-links-and-mobile-app-architecture – Ming Li May 11 '15 at 19:19
  • Thanks for your answer Ming. I have watched the video and received a better idea of how to do this. – Simon May 13 '15 at 20:40
  • 2
    @MingLi I don't understand, I'm having an Android application that using Facebook share dialog to share a Facebook page's link, and I want when other users tap on this post (via their mobiles) to be redirected to my app on GP or launch my app (if installed) with data that I can use to view this post in my app ... So is it possible to accomplish this or not? – Ashraf Alshahawy Jun 05 '15 at 04:05
  • If you're sharing an URL that doesn't belong to you (an FB page in this case), you should not expect it to open your app. – Ming Li Jun 05 '15 at 14:55
  • @Simon can you share your findings? How do you create multiple deeplinks (`myapp://story/1234`, `myapp://story/5678`, etc) with a single web url (`http://fb.me/xxx`) – Van Du Tran Sep 23 '15 at 15:43
  • You can now use this tool to create fb.me app link urls: https://developers.facebook.com/tools/applinkshost – Ming Li Sep 23 '15 at 22:02
  • @Ming Li sorry if I bother. I don’t understand the fact that applinks can’t be created from mobile. How would you deep link to different posts with a single fb.me url? I can create one manually with the tool, but then I wouldn’t be able to link to hundreds of different stories in my app. How is this solved? – natario Feb 04 '16 at 19:46
  • I’m asking because this answer is now pretty old and you talk about things coming. Maybe we can create new applinks for each story shared with an http request? – natario Feb 04 '16 at 19:57
  • You can use a single fb.me url as the mechanism to open your app, and then use query parameters to determine different stories. So your shared url would look like: fb.me/xxxx?story_id=1234, fb.me/xxxx?story_id=2345, and then in your app you would inspect the target_url, and parse out the story_id parameter. – Ming Li Feb 05 '16 at 22:52
  • @MingLi hi, is it possible to make an app link created from https://developers.facebook.com/tools/applinkshost has an thumb + install/open button? I created one and it works great, but it has only a title and fb.me.. Thank you. – Alex Kosyakov Jul 21 '16 at 10:31