在构建iOS应用时出现此错误。
我在此处大胆显示的行上显示错误
这是我的代码
@available(iOS 8.0, *)
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
**guard let dynamicLinks = DynamicLinks.dynamicLinks() else {**
return false
}
let handled = dynamicLinks.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
self.openURL(url: userActivity.webpageURL!)
}
if !handled {
if let url = userActivity.webpageURL?.absoluteString {
self.openURL(url: URL(string: url)!)
}
}
return handled
}
答案 0 :(得分:0)
显然DynamicLinks.dynamicLinks()
不会产生可选结果。将您的代码更改为此:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
let dl = DynamicLinks.dynamicLinks()
let handled = dl.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
self.openURL(url: userActivity.webpageURL!)
}
if !handled {
if let url = userActivity.webpageURL?.absoluteString {
self.openURL(url: URL(string: url)!)
}
}
return handled
}