- It is usual to use one
universal link
in one app. - It is also usual to use one
universal link
in one app for different scheme witch is using different bundle Id. - But it is unusual for mutable apps installed in the same device which are using mutable
universal link
in different priority.
For QA Testing, we’re setting some
Debug
,InHouse
,Release-Candidate
intoapple-app-site-association
.There’s no problems happened befor, because users can’t install aDebug
version, and also the test device did not have to install a life version.
What is universal link
If you already know what isuniversal link
you can skip this part
If you don’t know what isuniversal link
you should read this apple’s doc first =>
clickMe
And this is a simple description↓
universal link
is a technique that can make your apps wake up and deep linking to a target page while user click some normal url likehttps://shaggon.com/man/322113
in safari,mail,message or social media apps.
There’re only two steps to implementation
universal link
- Add the domain(for example:
applinks:shaggon.com
) in Capabilities => Associated Domains - Add a file named
apple-app-site-association
at the root of the server, make sureshaggon.com/apple-app-site-association
is visible. content is like below↓
123456789101112131415{"applinks": {"apps": [],"details": [{"appID": "9JA89QQLNQ.com.apple.wwdc","paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]},{"appID": "ABCD1234.com.apple.wwdc","paths": [ "*" ]}]}}- Add the domain(for example:
The priority
Let’s back to the question
mutable apps installed in the same device which are using mutable
universal link
in different priority
We can find this in apple’s Doc:
The value of the details key is an array of dictionaries, one dictionary per app that your website supports. The order of the dictionaries in the array determines the order the system follows when looking for a match, so you can specify an app to handle a particular part of your website.
It looks like we can adjust the priorities of the dictionary inside the array of details
to make that work.
Let’s try it!
- PREPARE
https://shaggon.com/apple-app-site-association
<–A First
https://www.doruby.com/apple-app-site-association
<–B First
- A clean Simulator iPhone 7
- Installed app
A
- Installed app
B
- TEST
Device installed A&B | Device installed A Only | Device installed B Only | |
---|---|---|---|
A First | A Opened | A Opened | B Opened |
B First | B Opened | A Opened | B Opened |
CONCLUSION
Just like apple’s doc said,universal link
dose have the priority for different apps, what you need to do is to change the order of the different apps inside the array of detail
.
- 一个app使用一个
universal link
很普遍 - 一个app的多个使用不同bundle Id的scheme共用一个
universal link
也很常见 - 多个app使用多个
universal link
且在同时安装多个app的设备上需要保证不一样的link实现不一样的跳转优先级这个就不常见了。
我们天生的会把
Debug
,InHouse
,Release-Candidate
等的记录填写在apple-app-site-association
中,以供QA在测试机上使用。我们没有发生过任何问题,因为正式用户不可能安装任何非life版本,而测试机也不怎么安装life版本。
什么是universal link
如果你已经知道universal link
是什么的话可以先略过这一部分
如果你不明白什么是universal link
你可以先阅读这份苹果的文档 =>
点我
然后下面是一份简单浅显的说明↓
universal link
是一种可以让iOS用户通过在浏览器、邮件、短信、或社交软件中点击一个普通的url例如https://shaggon.com/man/322113
而直接唤醒app并深度链接到指定页面的技术。
实现
universal link
只需要做两步- 在工程的Capabilities => Associated Domains中加入domain名字,例如
applinks:shaggon.com
- 在domain所对应的网站根目录下添加如下的一个名叫
apple-app-site-association
的文件,使得shaggon.com/apple-app-site-association
可供访问。内容如下↓需要关注和修改的点在details下面的一个包含着多个字典的数组中,它用来描述这个universal link
的哪些path被哪个team的哪个bundleID的app所支持。
123456789101112131415{"applinks": {"apps": [],"details": [{"appID": "9JA89QQLNQ.com.apple.wwdc","paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]},{"appID": "ABCD1234.com.apple.wwdc","paths": [ "*" ]}]}}- 在工程的Capabilities => Associated Domains中加入domain名字,例如
优先级问题
让我们再次回到问题
多个app使用多个universal link且在同时安装多个app的设备上需要保证不一样的link实现不一样的跳转优先级
在苹果的文档中我们可以发现这样一句话:
The value of the details key is an array of dictionaries, one dictionary per app that your website supports. The order of the dictionaries in the array determines the order the system follows when looking for a match, so you can specify an app to handle a particular part of your website.
看起来我们可以通过在details这个数组中调整内容的优先顺序来达到目的。
那到底行不行呢?我们来测测看。
- 准备
https://shaggon.com/apple-app-site-association
<–A First
https://www.doruby.com/apple-app-site-association
<–B First
- A clean Simulator iPhone 7
- Installed app
A
- Installed app
B
- 测试
Device installed A&B | Device installed A Only | Device installed B Only | |
---|---|---|---|
A First | A Opened | A Opened | B Opened |
B First | B Opened | A Opened | B Opened |
结论
就如苹果文档中所说的那样,universal link
是存在跳转的优先级的,只需要修改details这个数组中的内容的顺序即可。