Universal Links(通用链接) 看苹果官方文档更易理解
当支持了Universal Links
已安装app,点击链接,进入到app不需要通过Safari
未安装app,点击链接,进入到网页
相比Custom URL scheme 更灵活更安全
相对优点: Unique + Secure + Flexible + Simple + Private
配置需要三步
- 创建一个名字为 apple-app-site-association 的文件,内容为关于URLs的JSON数据.
- 把配置好的apple-app-site-association 文件上传到HTTPS服务器,可以将文件放在服务器的根目录(root)或.known子目录中
https://<domain>/apple-app-site-association
https://<domain>/.well-known/apple-app-site-association
- 配置app Associated Domains
apple-app-site-association↓↓↓↓↓↓
// 苹果官方例子
------------------------------------------------------------------------------
{
"applinks": {
"apps": [],
"details": [
{
"appID": "9JA89QQLNQ.com.apple.wwdc",
"paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]
},
{
"appID": "ABCD1234.com.apple.wwdc",
"paths": [ "*" ]
}
]
}
}
------------------------------------------------------------------------------
// 随便写的
------------------------------------------------------------------------------
{
"applinks": {
"apps": [],
"details": [
{
"appID": "6A66A6R66T.com.9ku.music",
"paths": [ "/ulink/*"]
}
]
}
}
------------------------------------------------------------------------------
注解:
- apps : 必须存在且为空数组
- appID : App ID Prefix + Bundle ID (中间用点连接)
- paths : 对应域名中的path,用于过滤可以跳转到App的链接,匹配的优先级是从左至右依次降低
1. * : 通配符
2. ? : (匹配任何单个字符,例: /foo/*/bar/201?/mypage)
3. NOT: 指定不应作为通用链接处理的区域
// "paths": [ "/wwdc/news/", "NOT /videos/wwdc/2010/*", "/videos/wwdc/201?/*"]
// 用于在路径数组中指定网站路径的字符串区分大小写。
开启 Associated Domains 服务↓↓↓↓↓↓
Apple Developer 配置 Identifiers
Xcode 配置 Associated Domains
链接使用:https://jintian.baimokc.com/ulink/ (后边随便跟)
客户端处理通用链接
- 可通过
5+ API
的 plus.runtime.launcher 判断应用启动来源,如果其值为uniLink
则表示通过通用链接启动应用。 - 可通过
5+ API
的 plus.runtime.arguments 获取启动参数,通用链接启动的情况将返回完整的通用链接地址。
iOS H5打开App(通用链接)
百度翻译
Universal Links 实现细节
Universal Links(一) —— 基本配置和使用示例(一)
网友评论