我在应用程序中使用通用链接。
我进行这样的功能。在Xcode和开发者帐户中启用关联域。
我在Xcode关联域中编写:applinks:laundry.com
使用代码将苹果应用程序站点关联到服务器:
{"applinks": {"apps": [],
"details": [{"paths": ["*"],
"appID": "Sm4Gn629J2.com.LaundryLive"}]}}
我在AppDelegate类中编写了以下代码,即使它也不起作用,请帮忙。
//Universal links in swift delegatemethod.
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool
{
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
let url = userActivity.webpageURL!
let userurl = url.absoluteString
// print(url.absoluteString)
//handle url
if userurl != "", defaultValues.value(forKey: accessToken) != nil
{
print("user url is:",userurl)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Pickup", bundle: nil)
let innerPage: PickupController = mainStoryboard.instantiateViewController(withIdentifier: "PickupController") as! PickupController
innerPage.selectedfrom = "Deeplink"
self.window?.rootViewController = innerPage
}else{
setRootControllerBeforeLogin()
}
}
return true
}