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

后端 未结 4 991
南旧
南旧 2021-01-12 17:00

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?

相关标签:
4条回答
  • 2021-01-12 17:32

    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.

    0 讨论(0)
  • 2021-01-12 17:34

    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.

    0 讨论(0)
  • 2021-01-12 17:40

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

    0 讨论(0)
  • 2021-01-12 17:54

    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.

    0 讨论(0)
提交回复
热议问题