Skip to content

Instantly share code, notes, and snippets.

@rsevil
Last active October 18, 2023 02:35
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rsevil/377690cef7bde5fe6825e3d248af035d to your computer and use it in GitHub Desktop.
Save rsevil/377690cef7bde5fe6825e3d248af035d to your computer and use it in GitHub Desktop.
Dynamic links - Applinks integration
@Aung-Myint-Thein
Copy link

Great! This one works for like charm for us especially for Facebook Android App.

@Aung-Myint-Thein
Copy link

In my first time trying, it is working. Then in second time and after I generate dynamic links manually, FB in app browser opens only web version.. Any more clue and tip, bro?

@rsevil
Copy link
Author

rsevil commented Feb 27, 2020

Hi @Aung-Myint-Thein,

Did you try inspecting the url with the Facebook Sharing Debugger on which you're exposing the applinks_dynamiclinks_proxy.js?

If not, I recommend you to try it and review what data is extracting from your link.

It once happened to me that all was working under a staging url and when I got it in production it wasn't working and the problem was that I was using a propiertary certificate and because of that facebook wasn't reading the data accordingly.

Hope that it helps

@Aung-Myint-Thein
Copy link

Hi @rsevil,

Thanks for the recommendation. I tried the debugger and look like it is working fine. It didn't capture all the al:ios and al:android tags. I think what happened is the redirection occurred before the debugger crawl the data and I attached the screenshot. However, look like Firebase Dynamic Link cannot detect Facebook Mobile Browser and it loads the web version.

Screenshot 2020-02-27 at 9 18 07 AM

Is this supposed to happen? Am I missing something to redirect the Facebook Android App to deep link to my app? :(

By the way, all the dynamic links I tested so far are generated manually by API. When I try with a dynamic link generated from console, it directs me to Play Store page instead of the app. Is it the normal flow.?

@rsevil
Copy link
Author

rsevil commented Feb 28, 2020

Hi @Aung-Myint-Thein,

Just in case I re tested my app on production environment and it keeps working so we're missing something here.

There are two things that came to my mind while thinking about why this solution is not working as expected for you:

  1. I noticed from the image that you posted that the inspector is detecting an og:url meta tag attribute, please try removing it.
    I remember that when I was dealing with this integration at first it was all working good but then when I added a bunch of metas it broke (og:url was one of them). So I removed all extra metas and kept only the ones from android and iOS, and I got it working again, so then I added each one of the other metas and tested them one by one that it kept working, it was a hard and painful task but I ended up with all those metas that are in the gist (those are the ones that I'm sure that don't cause problems), and not adding again that og:url meta again.

  2. How did you configured your AndroidManifest regarding on the Intents required by dynamic links to launch your app?
    Have a look at the Facebook Applinks android documentation as this is the pain point that you're suffering.

Please try no.1 first and tell me if you got it working or if you have more problems I'll be grad to keep helping you out.

@Aung-Myint-Thein
Copy link

Hi @rsevil

Thanks for replying and suggesting.

My intent is as following:

<intent-filter android:autoVerify="true">
          <action android:name="android.intent.action.VIEW"/>
          <category android:name="android.intent.category.DEFAULT"/>
          <category android:name="android.intent.category.BROWSABLE"/>
          <data android:host="myanlearn.page.link" android:scheme="http"/>
          <data android:host="myanlearn.page.link" android:scheme="https"/>
</intent-filter>

I tried the no 1 and it is still not working.

I check my link in debug view and found out that I am setting android fall back link. When I remove the option and create link again, now the Facebook link is redirecting me to Play Store. So, I think the issue is Facebook Mobile Broswer cannot open or pass the intent link to Android system? (Sorry I am not android developer hehe just guessing) I have implementation 'com.facebook.android:facebook-applinks:[4,5)' in my build.gradle but I am using RN.

Any more clues..? Really appreciate your help!

Regards,
Aung

@Aung-Myint-Thein
Copy link

Oh it is working now.. I just removed the proxy page.. and it is working..

@Aung-Myint-Thein
Copy link

After more investigation, I found out that the issue is in Firebase API to generate dynamic link short links. If there are socialMetaTagInfo data, the link is going to be broken. However, if there is no data for socialMetaTagInfo section, the link will work.

@rsevil
Copy link
Author

rsevil commented Feb 28, 2020

Hi @Aung-Myint-Thein,

Great news that you got it working, it seems that Firebase "sort of" fixed the problem with Facebook, I don't really know. Although it's really awful that everything breaks when using socialMetaTagInfo section.

I know the magic that makes Facebook open the app when you share a link are the applinks meta tags, Facebook reads them and directly executes the Intent on your app to open it. Another thing that you may not be needing is installing the Facebook Applinks SDK, because Firebase reads the Intent data itself.

In my case, I needed this "proxy page" because at that moment it didn't work by any manner and I had to deliver a working product to one customer so I couldn't wait for Firebase guys to fix it.

Have a great day!

@Aung-Myint-Thein
Copy link

Now iOS is breaking.. it only opens the app but not deep link.. it doesn't even show the preview page in iOS .. what a day I am having! haha Thanks, bro. really appreciate it.

@Aung-Myint-Thein
Copy link

Ah I found that

without social meta tag, iOS won't work but Android will work.
with social meta tag, iOS will work but Android won't work.

@nvtuan96
Copy link

I have tried but DynamicLinks.DynamicLinkReceived is not fired.

@ubarua123
Copy link

What steps do I need to do in order for this to work? I am not a react/angular/JS dev. As in I need create an html and paste this code etc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment