iOS Universal link
http://www.cocoachina.com/ios/20150902/13321.html
https://yohunl.com/ios-universal-links-tong-yong-lian-jie/
application:continueUserActivity:restorationHanler:
application:willContinueUserActivityWithType:
1, 添加域名
Capabilities
applinks:www.domain.com
applinks:domain.com
打開Capabilities開關(guān)后艺谆,自動生成xxx.entitlements文件
2,設(shè)置好bundle identifier
com.domain.demo2
3,創(chuàng)建apple-app-site-association文件
{
"applinks":{
"apps":[],
"details":[
{
"appID":"9JVMQ7S4HD.com.domain.demo2"
"paths":["*"]
},
{
"appID":"9JVMQ7S4HD.com.domain.demo3"
"paths":["*"]
}
]
}
}
{
"applinks": {
"apps": [],
"details": [
{
"appID": "KS7QAPBMXA.com.jianshu.Hugo",
"paths": [ "/p/*", "/c/*", "/u/*", "/nb/*", "/collection/*", "/users/*", "/notebooks/*", "NOT /users/auth/*" ]
}
]
}
}
上傳apple-app-site-association文件到web server服務(wù)器根目錄下面观蜗。
需要https支持咧栗∧嫣穑客戶端訪問需要通過https訪問才可以虱肄。并且不能重定向。
4交煞,測試咏窿。
在appdelegate文件中實現(xiàn)協(xié)議application:continueUserActivity:restorationHanler:方法
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler
{
if([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *webURL = userActivity.webpageURL;
if ([webURL.host isEqualToString:@"domain.com"]) {
//跳轉(zhuǎn)到對應(yīng)的頁面
} else {
//不能識別,用瀏覽器打開
[[UIApplication sharedApplication] openURL:webURL];
}
}
return YES;
}
5素征,例子
http://www.jackivers.me/blog/2015/9/17/list-of-universal-link-ios-9-apps
->在聊天記錄中點擊鏈接:https://twitter.com/mchappell51
在微信瀏覽器中打開
->然后點擊導(dǎo)航欄右上角按鈕集嵌,在safri瀏覽器中打開
->如果安裝了twitter等曼,會自動跳轉(zhuǎn)到twitter app颗搂,如果沒有安裝似舵,則會跳轉(zhuǎn)到該網(wǎng)頁铐殃。
自定義鏈接
iOS URL types
URL identifier
URL schemes
http://www.reibang.com/p/feecacacdefd