Tuesday, 10 November 2015

Facebook App Deep Linking - Andoid

One of the most interesting aspects of sharing to Facebook from your app is that when people engage with the feed stories posted from your app, those stories can send people to your app or your app's Google Play listing, driving traffic and app installs. You can implement this behavior using App Links.

   App link Flow


Facebook's Mobile Hosting API for App Links:


If your application doesn't have a website for content you want to share to Facebook, you don't have public web URLs which you can annotate to support App Links.

For these types of apps, Facebook provides an App Links Hosting API that will host App Links for you. With the Hosting API you can create and manage your App Links for all the mobile environments you support.

This is the typical flow to configure an App Link for a piece of content:
  1. Create a new App Link object. You can set up an object for one platform or several at the same time.
  2. Save the App Link object ID that's returned.
  3. Use that ID to get the URL you can use to share the content.
  4. Configure additional platforms that you support.
  5. If supporting Android, configure your app's manifest file for the configured URLs.

Please follow below steps for generate app linking.


For web service, In request Params we need to send below parameters.

iOS: url, name
Android: url, name

Step #1: Generate App Access Token (Ref. https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens)

GET /oauth/access_token?     client_id={app-id}    &client_secret={app-secret}    &grant_type=client_credentials


Step #2: Generate App Link using generated App Access Token (Ref. https://developers.facebook.com/docs/applinks/hosting-api)


You create a new App Link object for a content targeted to iOS & Android  like this

curl https://graph.facebook.com/app/app_link_hosts \
-F access_token="APP_ACCESS_TOKEN" \
-F name="iOS App Link Object Example" \
-F ios=' [
    {
      "url" : "applinkFB://showApp/54eee6292658c7df25000004",
      "app_store_id" : 570281083,
      "app_name" : “appName”,
    },
  ]' \
-F android=' [
    {
      "url" : "applinkFB://showApp/54eee6292658c7df25000004",
      "package" : "com.packagename”,
      "app_name" : “appName”,
    },
  ]' \

-F web=' {
    "should_fallback" : false,
  }'


A successful call returns an ID that represents the App Link object hosted on Facebook,
for example:

Return : {"id":"643402985734254"}

Step #3: Using generated ID(YOUR_APP_LINK_HOST_ID) which represents the App Link, you need to call another API which will return "canonical_url"


You can retrieve the canonical URL that points to your new App Link object through this API call:

curl -G https://graph.facebook.com/YOUR_APP_LINK_HOST_ID \
-d access_token="APP_ACCESS_TOKEN" \
-d fields=canonical_url \
-d pretty=true

Where YOUR_APP_LINK_HOST_ID represents the id returned from creating your App Link object. Your response will look like this:

Return:
{
   "canonical_url": "https://fb.me/643402985734254",   "id": "643402985734254"
}


Support sharesample URLs in Android

When a shared link is tapped your Android app is launched through the URL specified in the App Link object you just created (if you didn't specify a url, then it will use the canonical URL - i.e. the https://fb.me/xxxxx URL). To set up your app to respond to this URL, you need to add an intent filter in your app's manifest file.

The filter should respond to the applinkFB scheme (if you didn't specify a URL, then your filter should respond to the fb.me host and https scheme), handle implicit intents, and accept the ACTION_VIEW action. The example below adds an intent filter to the MainActivity that handles this:



    ...
    
        
        
        
        
    


Once you've set up your web pages based App Links, 
you're ready to handle incoming links to your app.

Handling incoming links

To ensure an engaging user experience, you should process the incoming intent information when your app is activated and direct the person to the object featured in the story they're coming from. 

For example, if I see a story on my Facebook feed about one of my friends 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.

If you use the App Links Hosting API, the Intent data will look like this:


data: "applinkFB://showApp/54eee6292658c7df25000004?target_url=https%3A%2F%2Ffb.me%2F643402985734299"
extras:
  al_applink_data: <Bundle containing App Link data>

In the code sample below, we're simply logging the target URL, but you should direct people through the appropriated flow for your app:


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(this); 
    ...
    Uri targetUrl =
      AppLinks.getTargetUrlFromInboundIntent(this, getIntent());
    if (targetUrl != null) {
        Log.i("Activity", "App Link Target URL: " + targetUrl.toString());
    }
}

47 comments:

  1. nice blogs.
    Route Guide Services
    SMS Route Guide ACT Gen7 Or Act Gen10 Or ACT Gen30 Unsub Or Stop Or Deact,Rs.30/30 Days Or Rs 10/10days Or Rs7/7days.

    ReplyDelete
  2. thanks for sharing wonderful information from your blog. and great doing in this about coding. keep update more useful information.
    SEO Training in Chennai

    ReplyDelete
  3. FITA is the leading IT training institute in Chennai offering professional training on more than 125+ IT courses by experienced professionals. Here, we offer 100% practical and placement oriented training that assist students to get placed in leading MNCs with good salary package. Android Training in Chennai

    ReplyDelete

  4. Thank you for having taken your time to provide us with your valuable information relating to your stay with us.we are sincerely concerned.., Most importantly, you Keepit the major...
    hadoop Training in Chennai

    ReplyDelete
  5. I always prefer to read the quality content and this thing I found in you post. Thanks for sharing.A very good resource for everybody that wants to read a good blog.

    Google App Integration Madurai

    ReplyDelete
  6. Wanna great article that very useful. All things which specify is a very interesting for read.SEO Company in
    Chennai

    ReplyDelete
  7. Great information provided about Android Training . I appreciate your work.

    ReplyDelete
  8. Great information provided about Android Training . I appreciate your work.

    ReplyDelete
  9. Great post.
    Thanks for sharing. Picked up some good and valuable insight.
    Android Training in Chennai

    ReplyDelete

  10. interesting blog. It would be great if you can provide more details about it. Thanks you

    Java and J2EE Training in Chennai - AmitySoft

    ReplyDelete
  11. good informative blog.I got some new techniques to link facebook with googles Api ,It really helps to teach our students in android development program Thanks for the post

    ReplyDelete
  12. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing

    dot net training in chennai

    php training in chennai

    java training in chennai

    ReplyDelete
  13. for preparing bank exam and group exam , we are providing an online test model questions papers

    Bank Exam Questions and Answers

    Group Exam Questions and Answers

    ReplyDelete
  14. Thanks for sharing, I will bookmark and be back again....Facebook app development

    ReplyDelete
  15. Thanks for sharing this informative articles ..glad to visit this blog.

    Best Linux Training in Chennai

    ReplyDelete
  16. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog, I will keep visiting this blog very often.
    Facebook

    ReplyDelete
  17. I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article. I enjoyed every little bit part of it and I will be waiting for the new updates.
    Facebook app development company

    ReplyDelete
  18. This was so useful and informative. The article helped me to learn something new.
    Android Training in Chennai

    ReplyDelete
  19. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Mobile App Development Company in Chennai
    Web Design Company in Chennai
    Web development Company in Chennai

    ReplyDelete
  20. "Great post. Keep it up. Thanks for advice. It is wonderful information for me. "!!
    mobile app development framework

    ReplyDelete

  21. Wow.. Its really very good information Facebook app deep linking. I hope you will update more soon.Know more about Facebook app deep linking check out Magento Connector

    ReplyDelete
  22. Thanks for posting useful information.You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...Really it was an awesome article...very interesting to read..
    please sharing like this information......
    Android training in chennai
    Ios training in chennai




    ReplyDelete
  23. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    Mobile App Development Company
    Mobile App Development Company
    Mobile app Development Companies

    ReplyDelete
  24. Really, these quotes are the holistic approach towards mindfulness. In fact, all of your posts are. Proudly saying I’m getting fruitfulness out of it what you write and share. Thank you so much to both of you.
    Office Interior Designers in Coimbatore

    ReplyDelete
  25. I simply want to say I’m very new to blogs and actually loved you’re blog site. Almost certainly I’m going to bookmark your blog post . You absolutely come with great well written articles. Thanks a lot for sharing your blog.
    Best Android Training in Velachery | android development course fees in chennai

    ReplyDelete
  26. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.Android Training in chennai | Best Android Training in chennai

    ReplyDelete
  27. This information is impressive; I am inspired by your post writing style & how continuously you describe this topic...Android Training in Bangalore

    ReplyDelete
  28. This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...

    Android App Development Company

    ReplyDelete
  29. Very Informative! This blog is great source of information which is very useful for me. Thank you very much for sharing this!
    Excellent blog..Thanks for your ideas. android development company ludhiana

    ReplyDelete
  30. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Android Online Training

    ReplyDelete
  31. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    Web Design Development Company
    Web design Company in Chennai
    Web development Company in Chennai

    ReplyDelete
  32. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete
  33. it is really amazing...thanks for sharing....provide more useful information...
    Mobile app development company

    ReplyDelete
  34. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
    Fitness SMS
    Salon SMS
    Investor Relation SMS

    ReplyDelete
  35. Wow, the application is very unique and I am looking forward to using it soon and understand how it functions. Thanks for sharing this important technological article with us. I have found it to be not only up to date but also informative. Students can access our professional literature review site by clicking on Well Analyzed Lit Reviews.

    ReplyDelete
  36. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    iOS App Development Company

    ReplyDelete
  37. Thanks...Great information provided about Android Training . I appreciate your work.
    top android app development companies


    ReplyDelete
  38. This ARTICLE really helpful people to start the Android Development. I hope everyone using this to growing their business in public.

    Android training in Nagpur

    ReplyDelete