11

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?

Vishal Patoliya ツ
  • 3,170
  • 4
  • 24
  • 45

5 Answers5

14

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.

Johnson_145
  • 1,994
  • 1
  • 17
  • 26
  • Using a new subdomain in the same project (AKA: URL prefix) is not working for me since the apple-app-site-association json is the same for each subdomain. How do you manage to make it work? – csanchez Nov 05 '20 at 19:55
  • You're referring to the approach described in "Solution 1: Using multiple (sub)domains", right? In that case it should be okay that all `apple-app-site-association` are identical. As described above, it should be sufficient if you use different `Associated Domains Entitlement` configurations. I.e., theoretically all targets could use any of the subdomains listed in the `apple-app-site-association`, but instead they will listen only to the ones you add to the local `Associated Domains Entitlement` config (the latter must of course be a subset of the former). – Johnson_145 Nov 06 '20 at 12:32
  • If I use solution 2 custom domain and "NONE" I get the following error on the firebase console: "https://go.myapp.app is not connected properly Your Dynamic Links path prefix is not configured in firebase.json. Check your firebase.json configuration and try again." Only AUTO seems to work. – MadMac May 09 '22 at 01:43
1

@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..?

lobstah
  • 871
  • 7
  • 12
0

For deep link you would be using the application's bundle identifier. Your other targets would have different identifiers. Use UIApplicationShortcutItems in the Info.plist and add entries for your deep link shirt cuts in respective plist files.

Sharath
  • 344
  • 2
  • 10
  • every time open main project when i click in link which generate from firebase and not open different target which i give ibi for generate deeplink @Shatath – Vishal Patoliya ツ Jan 11 '17 at 05:15
  • I did not see any such key in plist. Do you mean we should add it manually ? Also since I'm using same firebase project for both target, so in this case deeplink shortcut will be same. This is what you mean ? @Sharath – Vishal Patoliya ツ Jan 12 '17 at 07:27
0

You need to create a different project in Firebase for each of your target if you want them to get a different app domain. If you don't, they are not distinguishable by the universal link system of iOS.

That means you can't create a single project with several application in it.

CedricSoubrie
  • 6,657
  • 2
  • 39
  • 44
0

Using the same custom domain is possible by overriding the default apple-app-site-association.

Set http headers in firebase.json.

{
  "hosting": {
    "appAssociation": "AUTO",
    "public": "public",
    "ignore": ["firebase.json"],
    "rewrites": [{ "source": "/**", "dynamicLinks": true }],
    "headers": [
      {
        "source": "/.well-known/apple-app-site-association",
        "headers": [{ "key": "Content-Type", "value": "application/json" }]
      },
      {
        "source": "/apple-app-site-association",
        "headers": [{ "key": "Content-Type", "value": "application/json" }]
      }
    ]
  }
}

Create public/apple-app-site-association (the above config assumes files will be in the public folder; modify as necessary). isi is the Apple Store numeric app id.

{
  "applinks": {
    "details": [
      {
        "appIDs": ["ABCDEF1234.com.example.foo"],
        "components": [{ "?": { "isi": "112233" } }]
      },
      {
        "appIDs": ["ABCDEF1234.com.example.bar"],
        "components": [{ "?": { "isi": "445566" } }]
      }
    ]
  }
}

Create symlink public/.well-known/apple-app-site-association pointing to public/apple-app-site-association (or just copy the file).

Deploy with the firebase cli firebase deploy --only hosting. Will probably work right away in development, but Apple warns caching may result in this taking a week in production.


The above config assumes manually constructed dynamic links. Using clean links requires a different pattern matcher. For example, if https://apps.example.com/foo/clean-link should launch com.example.foo and https://apps.example.com/bar/clean-link should launch com.example.bar, add to the "components" array { "/": "/foo/*" } and { "/": "/bar/*" } respectively. These techniques can be combined to support both use cases.

Alpha
  • 1
  • 2