How to get facebook app link if app wasn't installed

前端 未结 5 1106
余生分开走
余生分开走 2021-02-05 14:32

How can I get the app link data if my app wasn\'t installed when the user tapped a deep link in the facebook app? There is surprisingly little documentation from facebook on thi

5条回答
  •  攒了一身酷
    2021-02-05 15:20

    I work at branch.io, which does all this stuff for you for free and works outside of Facebook as well, and we figured out a way to pass App Links through the install. I'll share how we built it.

    First, you'll need to collect the Google Advertising ID, so make sure that you drop in Google Play Services to your project. To do so, just add this to your gradle file:

    compile 'com.google.android.gms:play-services:7.5.0'

    Now, it will require you to make an network request every time the app opens to check if the user originated from Facebook, but it's not too complicated. On app open, POST to the following endpoint with your Facebook App ID, App Access Token and the Google Advertising ID.

    https://graph.facebook.com//activities?access_token=&event=DEFERRED_APP_LINK&advertiser_id=&advertiser_tracking_enabled=1&application_tracking_enabled=1
    

    GAID: You can retrieve the Google Advertising ID with this method:

    String gaid = AdvertisingIdClient.getAdvertisingIdInfo(this).getId();
    

    App access token: To get your access token, just make a GET call to the following endpoint:

    https://graph.facebook.com/oauth/access_token?client_id=&client_secret=&grant_type=client_credentials
    

    Then, when you create your Facebook stuff (ads, invites, etc), just drop in your deep link. This example shows a Branch link pasted in:

    If you don't want to deal with this, we have a native library with a callback executed on app session start, which will return all of your deep link params.

提交回复
热议问题