我试图处理开放的应用程序从通用链接点击。在iOS 13下面,它工作得很好,但对于iOS 13,它只运行在后台的应用程序。如果应用程序不工作前景或背景,单击链接将打开未调用的应用程序。继续用户活动功能。我还试着让它在现场委托将连接委托。但是仍然没有调用我的代码下面是什么问题?
场景委托
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
if connectionOptions.userActivities.first != nil {
self.scene(scene, continue: userActivity!)
}
}
APP委托
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if let userActivityDict = launchOptions?[.userActivityDictionary] as? [AnyHashable : Any],
let userActivity = userActivityDict["UIApplicationLaunchOptionsUserActivityKey"] as? NSUserActivity {
continueUserActivity(userActivity: userActivity)
}
return true
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
continueUserActivity(userActivity: userActivity)
return true
}
func continueUserActivity(userActivity : NSUserActivity){
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
let url = userActivity.webpageURL!
let dataDict:[String: String] = [AppLinkManager.appLinkExtraKey: url.absoluteString]
NotificationCenter.default.post(name: .didReceiveAppLink, object: nil, userInfo: dataDict)
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。