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

自闭症网瘾萝莉.ら 提交于 2020-06-22 19:00:47

问题


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?


回答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..?




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/41582867/firebase-dynamic-links-is-not-working-for-different-target-in-same-project-in-io

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!