Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Dynamic-Links is not working for different target in same project in iOS

Is the behaviour of Firebase Dynamic-Links is different for Android and iOS? How can I implement Firebase Dynamic-Links for the same project for a different target in iOS?

In Android, Firebase Dynamic-Links is working properly for different flavours, but in iOS Firebase Dynamic-Links is not working for different targets.

For iOS, what do I have to implement for Firebase Dynamic-Links with Firebase for the same project with different targets?

What is the actual reason for the difference in Firebase Dynamic-Links behaviour for Android and iOS? To implement Firebase Dynamic-Links for different targets, do I have to create a separate project for the same application?

like image 290
Vishal Patoliya ツ Avatar asked Jan 11 '17 04:01

Vishal Patoliya ツ


2 Answers

TLDR

Firebase Dynamic Links do not support using the same URL prefix for multiple iOS apps/targets contained in the same Firebase project. There are multiple workarounds though:


Solution 1: Using multiple (sub)domains

It works, if each iOS app uses its own (sub)domain for dynamic links. For instance, instead of using only pets.page.link for all targets, use cats.page.link for your first app target and dogs.page.link for your second app target. The crucial requirement for this is that each of your target's Associated Domains Entitlement contains only the (sub)domain(s) it should listen to.

Personally, I'm using this solution and it's working just fine.

Solution 2: Use a custom domain

If you insist on using the same domain for all targets, you should be able to solve this by using a custom domain along with some extra work.

Follow the official documentation to set up a custom domain like my-own-fancy-pet-app.com rather than using any of the URL prefixes natively provided by Firebase (like pets.page.link).

When creating your firebase.json file, do not use the suggested "appAssociation": "AUTO", option, but set it to NONE. This will prevent Firebase from automatically creating the problematic apple-app-site-association file (as well as the assetlinks.json). Use Firebase Hosting to serve manually-created versions instead. You can then use the apple-app-site-association to configure it to your needs, i.e. redirecting only particular paths to each target rather than matching all paths to all targets.

Disclaimer: I haven't tested this approach, because it hasn't been worth the extra work in my case.

Solution 3: Using multiple Firebase projects

Of course, you can simply create a new Firebase project for each of your targets. You can't use the same (sub)domain across multiple projects and thus you're forced to implicitly implement the solution 1.


Background

Why does it work on Android, but not on iOS?

On Android, the required assetlinks.json file maps full domains including all paths to a list of Android apps (or flavors). Whether a particular link is supported by a particular app, is determined by you by routing the desired paths locally in your Android Manifest file.

On iOS, it's the other way around: the required apple-app-site-association file determines which paths are matched to which apps. Unfortunately, you're not in charge of this file when using Firebase Dynamic Links and Firebase simply matches all paths of an URL to all apps contained in a Firebase project. Locally, you can only configure the Associated Domains Entitlement of your iOS app. However, the latter does handle only full domains including all pathes.

Firebase Dynamic Links limitations

Unfortunately, this limitation isn't mentioned anywhere in the official docs. However, it has been confirmed e.g. here or here. As stated in the first link, they used to plan to add this feature, but looks like they still haven't. I'll contact the support to ask for an update and request them to add at least an appropriate hint to the docs.


PS: I know this is a quite old question, and things may have been a little bit different at the time of asking. It's still an issue today though.

like image 180
Johnson_145 Avatar answered Oct 20 '22 00:10

Johnson_145


@VishalPatoliyaツ I asked Firebase developers about it, they said that this feature is not in their todo list) and proposed to make a request to support with argumentation why this possibility is needed. And maybe it will be implemented sometimes...

...though universal links have multiple app support. Here you can find understanding how it works: Supporting same domain on two different apps supporting universal links..?

like image 26
lobstah Avatar answered Oct 20 '22 01:10

lobstah