我在我的HTTPS根目录(kumpul.co.id/apple-app-site-association)中提供了apple-app-site-association,结果从https://branch.io/resources/aasa-validator/#resultsbox传递
我已将其配置为我的权利: applinks:kumpul.co.id
我把这个功能放在我的Appdelegate.swift中:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
NSLog("Check Universal Link")
// 1
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL,
let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
return false
}
print("url: \(url)")
print("component: \(components)")
// 2
if let match = MatchHandler.sharedInstance.items.filter({ $0.path == components.path}).first {
self.presentMatch(match)
return true
}
//3
let webpageUrl = URL(string: "http://www.kumpul.co.id")!
application.openURL(webpageUrl)
return false
}
对于路径,我设置“路径”:[“/ match / *”]因为链接将是 kumpul.co.id/match/play_2.html ,例如
但是当我点击WhatsApp或Line消息上的链接时,此功能根本没有被调用,当我点击链接时我看不到日志。我在这做错了什么?
答案 0 :(得分:1)
Line与Universal Links不兼容,因此测试用例无效。即使所有内容都配置完美,您的应用也无法在线路中点击通用链接时打开(您需要通过号召性用语按钮提供内容的网络预览,例如this - 顺便说一下,同样的问题存在on Facebook。
WhatsApp应该正常运行。如果您的应用在点击链接时甚至没有启动,则会出现配置问题。您可以尝试浏览this page上的一些问题排查步骤。如果您的应用 启动,那么您的配置是正确的,您应该验证continue userActivity