14

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 this issue.

I have a deep link https://fb.me/635533123230265

Which returns the HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>App Link</title>
<meta property="fb:app_id" content="619350481515196">
<meta property="al:android:url" content="instapanel://panel?utm_source=fb&amp;utm_medium=cpi&amp;utm_term=sf&amp;utm_campaign=PROPE">
<meta property="al:android:package" content="com.instapanel.android">
<meta property="al:android:app_name" content="Instapanel">
<meta property="al:web:should_fallback" content="false">
<meta http-equiv="refresh" content="0;url=http://play.google.com/store/apps/details?id=com.instapanel.android">
</head>
<body>Redirecting...</body>
</html>

If the app is already installed, AppLinkData appLinkData = AppLinkData.createFromActivity(activity); works perfectly.

But if the app was not installed, I believe I'm supposed to use AppLinkData.fetchDeferredAppLinkData. I can verify that within the facebook SDK it makes an HTTP request and receives JSON, but it never contains the deep link, just {"success":true}. Any ideas?

Here is my code:

// Fetch data immediately.
AppLinkData appLinkData = AppLinkData.createFromActivity(activity);
App.setAppLinkData(appLinkData);  // Handles appLinkData

// In case data is deferred because app wasn't installed yet.
AppLinkData.fetchDeferredAppLinkData(activity, new AppLinkData.CompletionHandler() {
    @Override
    public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
        App.setAppLinkData(appLinkData);  // Handles appLinkData. appLinkData is always null here.
    }
});
d2vid
  • 2,014
  • 1
  • 22
  • 25
  • 1
    Currently there's no deferred linking support for organically shared apps links. Deferred linking is only available for ad products. – Ming Li Nov 03 '14 at 21:57
  • Thanks @MingLi, I'm going to be running an ad campaign. Any recommendations about how to test that the app links are working? Just run an ad that targets myself, or do you know of anything more clever? – d2vid Nov 03 '14 at 21:58
  • Using "Ad Preview and Placements" - "View on mobile" to get the ad to show up in my feed. Still no deferred app link after installing from the Play Store. @MingLi does it literally have to be a real ad for deferred links to work, not just an ad preview? – d2vid Nov 03 '14 at 22:29
  • Hello, I face the exactly same issue. The ad on my fb feed takes me to play store and when I install it I get only {"success":true}. Have you solved this issue please? Thank you – bakua Nov 07 '14 at 09:42
  • I haven't been able to solve this issue, even when running a real ad campaign. Seems like facebook deferred app links on android might just be broken. It's also worrisome that a google search for "fetchDeferredAppLinkData" returns this question as one of the top hits, seems like this area is pretty unexplored. – d2vid Nov 10 '14 at 18:31
  • @MingLi is this still happening? I'm trying to use deferred links with AppLinks in my ios app. As fas as I can see in the documentation it says "fetchDeferredAppLink: Call this method from the main thread to fetch deferred applink data if you use Mobile App Engagement Ads" Is there a way to test if are they working before upload it in the App Store? Thanks – Joan Cardona May 26 '15 at 12:55
  • @d2vid, how are you getting AppLinkData.CompletionHandler()? AppLinkData only has an ICompletionHandler I can use. Did you create a concrete class that derives from that and are using it here? Just wondering how your CompletionHandler looks like. Thanks! – Euridice01 Nov 18 '16 at 21:31

5 Answers5

6

Looks like FB has fixed this issue now.

edit: Follow this for setting up deferred deep-linking: https://developers.facebook.com/docs/app-ads/deep-linking#deferred-deep-linking

This link for testing: https://developers.facebook.com/tools/app-ads-helper/

Go to App Ads Helper -> Select your App -> Test Deep Link -> Enter deep-link URL -> Check Send Deferred -> Send to Android.

Note: 1. You need to have FB app installed on your device and logged in to the same developer account for this to work. 2. Need to uninstall and reinstall the app after sending a deferred deep-link. Uninstall can be done before sending the link as well.

Vijay Raghavan
  • 126
  • 1
  • 6
  • Can you provide more feedback on what you did to make it work? It doesn't work for me at all. – Radu Jun 12 '15 at 12:24
  • Follow this for setting up deferred deep-linking: https://developers.facebook.com/docs/app-ads/deep-linking#deferred-deep-linking This link for testing: https://developers.facebook.com/tools/app-ads-helper/ Go to App Ads Helper -> Select your App -> Test Deep Link -> Enter deep-link URL -> Check Send Deferred -> Send to Android. Note: 1. You need to have FB app installed on your device and logged in to the same developer account for this to work. 2. Need to uninstall and reinstall the app after sending a deferred deep-link. Uninstall can be done before sending the link as well. – Vijay Raghavan Jul 14 '15 at 04:29
4

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/<APP ID>/activities?access_token=<APPACCESSTOKEN>&event=DEFERRED_APP_LINK&advertiser_id=<GAID>&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=<APPID>&client_secret=<APPSECRET>&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:

enter image description here

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.

Alex Austin
  • 1,142
  • 8
  • 11
  • Hi Alex, thanks for sharing! When the app opens, and makes a POST to the facebook endpoint above, what response(s) does Facebook respond with? Is it necessary to have used a deep link to get a response on that endpoint? I'm trying to answer the question: for a given app install, did it come from Facebook, eg did the user click an ad and then install. – waterlooalex Jul 26 '17 at 18:04
  • 1
    Hey Alex - You should use Branch since we handle this all for you :). To answer your question though, Facebook responds with a JSON dictionary with a key "applink_url" containing the value of the field so you'll need to put something there to pass through and I believe there are URI regex checks. Note that it only works if the user actually *clicks* on the ad - not view-through or anything like that. – Alex Austin Jul 28 '17 at 02:26
  • Thanks! Found the docs here: https://developers.facebook.com/docs/graph-api/reference/application/activities/ Tried using branch in a few scenarios (not this one), hit issues, haven't looked at it since. – waterlooalex Jul 28 '17 at 06:16
0

As of Dec 2, 2014 facebook deferred app links are broken on Android. I can get my app links to work when the app is already installed, but when the app is NOT already installed the app link is never sent to the app after it's installed.

I'm in touch with facebook, I'll post any updates here.

d2vid
  • 2,014
  • 1
  • 22
  • 25
0

As a FB team responses on https://developers.facebook.com/bugs/393947180805373:

It works when you are installing app from the new real ad (not test tool) at the first time.

Explanation:

Developer:

Flow At the first try. ( Not installed, using device 1 )

  1. Clicked the button the ad.
  2. Begin redirected to Google Play.
  3. installed my app on device 1.
  4. launched my app first time. >> result : I could see applinkdata.

-

  1. deleted my app on device 1 ( same device that i used in 1st test. )
  2. Clicked the button again the ad.
  3. Begin redirected to Google Play.
  4. installed my app on device 1.
  5. launched my app first time. >> result : I could not see applinkdata, i got null value. ( wonder why ? )

FB Team:

due to some technical constrains in our side the deferred deep link will fails when you send the ad to your own device using the ad preview tool

...

The behavior on device 1 is expected behavior. The app fetches the applink data from the server. When the server gets the request, it marks the ad-applink data as having been fetched. Subsequent requests do not return it. (Otherwise, every time you opened the app thereafter, it would load the applink, which would be a bad experience. The link should only be followed once.). Only if you create a new ad and click on it will the data get fetched again.

I hope it will help.

Best regards,

Jack

jczerski
  • 265
  • 2
  • 13
0

For developers: The following steps worked for me, 1. Uninstall the app 2. Send deep link form FB 3. click on the deeplink, to takes you to play store (don't install app) 4. Now debug the app 5. you'll find applinkData value in onDeferredAppLinkDataFetched event.