在我注册的应用中,我们通过电子邮件链接验证用户的电子邮件。用户收到带有验证链接的电子邮件,点击该电子邮件,然后该应用使用通用链接来呼叫verify()
。但是,我们看到有时用户会点击链接,该应用会打开,但不会调用该代码。
这里很难发现的是该错误是不连续的,我还没有设法重现它。可能是用户尝试点击gmail应用中的链接。
这就是我所拥有的:
in AppDelegate
in didFinishLaunchingWithOptions
if let activityDict = launchOptions?[UIApplication.LaunchOptionsKey.userActivityDictionary] as? [String : Any],
let userActivity = activityDict["UIApplicationLaunchOptionsUserActivityKey"] as? NSUserActivity,
userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let universalLink = userActivity.webpageURL {
if UniversalLinkManager.shared.openUniversalLink(url: universalLink) == true {
// link is being handled
return false
}
}
in continue userActivity: NSUserActivity
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
return UniversalLinkManager.shared.openUniversalLink(url: userActivity.webpageURL)
}
then in UniversalLinkManager I make the call to my server to verify the user.