例如这是我的网址:
https://apps.apple.com/{countrySortCode}/app/{appName}/id{APPID}?code={codeNumber}&domain={domainName}
我将通过电子邮件或文本将此 URL 发送给最终用户以安装我的应用程序。第一次安装后,我想知道该URL 的code value
and domain address
。
为了在 SceneDelegate 实现这一点:
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
print("userActivity", userActivity)
}
我还尝试了 AppDelegate 使用一些委托方法,例如:
override func updateUserActivityState(_ activity: NSUserActivity) {
print("updateUserActivityState--1")
if activity.activityType == NSUserActivityTypeBrowsingWeb {
let urlString = userActivity?.webpageURL!.absoluteString
print("***url: \(String(describing: urlString))")
let component = urlString?.components(separatedBy: "=")
guard let information = component else { return }
if information .count > 1, let code = information.last {
print("code: \(code)")
}
}
let urlString = userActivity?.webpageURL!.absoluteString
print("urlStrin", urlString!)
let userInfo1 = userActivity?.referrerURL?.absoluteString
print("userInfo1", userInfo1 as Any)
let userInfo2 = userActivity?.userInfo
print("userInfo2:", userInfo2 as Any)
}
private func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
print("NSUserActivity")
let userinfor = userActivity.userInfo as! NSDictionary
print("***userinfor: \(userinfor)")
return true
}
但我未能获得该信息。我在做什么错?我将如何从该 URL获取code value
and ?domain address
提前致谢。