10

I've made a dynamic link for users to share some contents in my app.

The link is working when I click a link in an HTML page using href tag on Android device.

It means, if the app is not installed, go to Play Store, else opening the app and I could receive deep link address.

But when the link is exactly same on other places like a facebook messenger or email etc. I click the link, then it's not working.

It's always redirected to Play Store even if my app is already installed.

What's the problem?

My code is here.

  • .java for receiving deep link

    GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(AppInvite.API)
            .build();
    
    boolean autoLaunchDeepLink = false;
    AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink)
            .setResultCallback(
                    new ResultCallback<AppInviteInvitationResult>() {
                        @Override
                        public void onResult(@NonNull AppInviteInvitationResult result) {
                            if (result.getStatus().isSuccess()) {
                                // Extract deep link from Intent
                                Intent intent = result.getInvitationIntent();
                                String deepLink = AppInviteReferral.getDeepLink(intent);
    
                                Log.e("sf", "### deep link : " + deepLink );
                            } else {
                                Log.d("asdf", "getInvitation: no deep link found.");
                            }
                        }
                    });
    
  • intent part of activity in AndroidManifest.xml

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
    
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
    
            <data
                android:host="mycode.app.goo.gl/"
                android:scheme="https"
                android:pathPattern=".*" />
        </intent-filter>  
    
  • dynamic link

    https://mycode.app.goo.gl/?link=web page address&al=my custom scheme for sharing&apn=my android app's package name

hshan
  • 335
  • 1
  • 3
  • 17
  • can you please post the code that you are using for, if the app is not installed, go to Play Store, else opening the app and I could receive deep link address. – Nainal Dec 19 '16 at 08:07
  • I just uploaded a part of my code. – hshan Dec 19 '16 at 09:59
  • I have contacted Firebase support. They were able to reproduce the issue with Facebook Messenger and they are currently investigating. I will write in this thread if I learn something new. – David Vávra Sep 02 '17 at 15:38
  • Did you find a solution? – Apurva Sep 20 '18 at 08:58

3 Answers3

8

We have implemented Firebase Dynamic Links according to this documentation https://firebase.google.com/docs/dynamic-links/ and they are working properly in all cases except of Facebook and Facebook Messenger app.

First we generate a dynamic link to our app:

Builder builder = new Builder()
  .scheme("https")
  .authority("winged-guild-133523.appspot.com")
  .appendPath("share")
  .appendQueryParameter("query", query);

Then we generate the long dynamic link:

Builder builder = new Builder()
  .scheme("https")
  .authority("zkkf4.app.goo.gl")
  .appendPath("")
  .appendQueryParameter("link", deepLink)
  .appendQueryParameter("apn", "com.mydomain.myapp");

Then we exchange the long dynamic link with a short link at https://firebasedynamiclinks.googleapis.com/v1/shortLinks and share it using intent:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, null));

If we share this link using Facebook app:

  • The short link is properly shared.
  • If the app is not installed, clicking on the link in Facebook app goes properly to Google Play and after installing the app the deep link is handled correctly.
  • If the app is installed, clicking on the link in Facebook app goes also to the Google Play and after clicking on open button, the deep link is not transferred to the app because Google Play do not pass referrer information to the app if installation has not been performed.

If we share this link using Facebook Messenger app:

So I see three problems here:

  • Facebook app is not properly detecting that the app is installed.
  • Facebook Messenger app shares a long dynamic link instead of short one.
  • Facebook Messenger app can detect that the app is installed but goes to the link instead of Google Play if the app is not installed.

Do anyone have any idea what is going on an how to solve those issues?

PS: Although this is irrelevant because the deep link handling in the app is working properly this is our manifest intent filter:

  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
  </intent-filter>

  <intent-filter android:label="@string/app_name">
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="http"/>
    <data android:scheme="https"/>
    <data android:host="winged-guild-133523.appspot.com"/>
    <data android:host="www.winged-guild-133523.appspot.com"/>
    <data android:pathPattern="/share.*"/>
  </intent-filter>
Blackhex
  • 1,632
  • 3
  • 20
  • 43
  • 1
    This is a response to my Firebase support request with the same text: "We have also received reports regarding Dynamic Links not working properly on Facebook. We're exploring potential solutions, but I can't share any details or timelines at this time. We'll keep your feedback in consideration moving forward though. Keep an eye out on our release notes for any further updates." – Blackhex Jan 05 '17 at 12:56
  • Thanks this pattern I looking for – Naveen Kumar M Jan 18 '17 at 08:58
  • Did you find a solution? – Apurva Sep 20 '18 at 08:58
  • Facing same issue here, almost 2020 / three years later – Josh Wolff Dec 19 '19 at 22:31
0
//Remove this lines 
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>

and  android:pathPattern=".*" /> //not required remove it also
and use android:scheme="http"
vishal
  • 21
  • 6
0

Same issue here. iOS and Facebook in-app browser.

According to this, it is still an open issue as of 12/19/19.

But, removing the "efr=1" parameter (in other words, you have to show the preview page) makes it work. That is what the developer who closed the issue stated, but of course this is not an ideal solution.

As one of the users on that same link explains, you can check if the user is using a Facebook in-app browser with this Javascript line:

..... - EDIT - removed this line of code---

I removed the above because it actually crashed when not in the Facebook app. I suggest this code below, which I tested on Chrome, Safari, Firefox Android iOS.

function isFacebookApp() {
    var ua = navigator.userAgent || navigator.vendor || window.opera;
    return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1);
}

It is the top-rated answer here.

.....

For me personally, this works somewhat because the users first go to my website, where I supply the dynamic link. So, my website handles the logic and only passes "efr=1" if the user is using a Facebook browser and iOS. Again, not ideal, so hopefully they will fix this longstanding issue.

It might be a bit, as the developed on that link said, "afaik it is currently not possible to open an app via universal link out of the Facebook, Messenger, or WeChat apps without using a preview page..."

Here is another Github issue for your reference.

Josh Wolff
  • 1,451
  • 1
  • 12
  • 32