iOS Universal Link(通用链接)

2019-04-18  本文已影响0人  _秃头少女_
场景:

用户通过点击链接直接跳转到APP (没有提示),如果手机没有安装app会选择浏览器打开(系统自己会判断是否安装了app)

要求:
1.必须是Https
2.app本地配置对应域名(such as applinks:www.mywebsite.com.Limit. this list to no more than about 20 to 30 domains.)****证书也要同步开通association domin功能的哦
屏幕快照 2019-04-18 下午5.13.12.png 屏幕快照 2019-04-18 下午4.59.37.png
3.web service 配置apple-app-site-association(json文件)

//文件放到服务器根目录下或者在根目录下新建.well-known 把apple-app-site-association放到里面

注意:apple-app-site-association的更新时机,app重新安装第一次启动会get请求apple-app-site-association文件,还有就是版本更新会请求文件,其他时间就算后台更新文件配置 app也不会拉取!

苹果原话https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW2

 Upload the apple-app-site-association file to your HTTPS web server. You can place the file at the root of your server or in the .well-known subdirectory.
{
    "applinks": {
        "apps": [],//这个必须为空数组
        "details": [
            {
                "appID": "9JA89QQLNQ.com.apple.wwdc",//开发者账号的teamID.bundleID
                "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]//支持打开app的路径 * 代表全路径
            },
            {
                "appID": "ABCD1234.com.apple.wwdc",
                "paths": [ "*" ]
            }
        ]
    }
}

当然苹果为了方便开发者,也提供了一个网页来验证我们编写的这个** apple-app-site-association **是否合法有效。

验证地址:https://search.developer.apple.com/appsearch-validation-tool/

4.在AppDelegate方法里实现自己的操作
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler{}

对比URL Scheme

URL Scheme
Universal Links

https://www.jianshu.com/p/53588cf8dbc8
https://blog.csdn.net/mo_xiao_mo/article/details/60954116

上一篇下一篇

猜你喜欢

热点阅读