gpt4 book ai didi

iOS 13 > 当应用程序被杀死且不在后台时,通用应用程序链接不起作用

转载 作者:行者123 更新时间:2023-12-03 23:35:05 24 4
gpt4 key购买 nike

知道为什么从 iOS 13 应用程序链接(通用链接)开始,这是通过 Apple-App-Site-Association 定义的停止工作?

我在 ApplicationDelegate 和 SceneDelegate 中有 2 个实现。
现在仅适用于 SceneDelegate 中的实现,并且仅当应用程序在后台时,如果我杀死应用程序,则不会调用 continueUserActivity 方法。我添加了触觉反馈来跟踪此方法调用,但它永远不会在 ActivityDelegate 或 SceneDelegate 中被调用。

// MARK: - Universal Links support
extension SceneDelegate {

func scene(_ scene: UIScene, willContinueUserActivityWithType userActivityType: String) {
print("[Scene] Will continue user activity: ", userActivityType)
let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.success)

}

func scene(_ scene: UIScene, didFailToContinueUserActivityWithType userActivityType: String, error: Error) {
print("[Scene] Did fail to continue user activity: ", userActivityType)
}

func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {

print("[Scene] Application continue user activity...")

if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
if let url = userActivity.webpageURL {
if !present(url: url) { UIApplication.shared.open(url, options: [:]) }
}
}
}

及 Application Delegate 案例
// MARK: - Universal Links support
extension AppDelegate {

func application(_ application: UIApplication, willContinueUserActivityWithType userActivityType: String) -> Bool {
print("[App] Will continue user activity: ", userActivityType)
let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.warning)
return true
}

func application(_ application: UIApplication, didFailToContinueUserActivityWithType userActivityType: String, error: Error) {
print("[App] Did fail to continue user activity: ", userActivityType)
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {

print("[App] Application continue user activity...")

if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
if let url = userActivity.webpageURL {
if !present(url: url) { UIApplication.shared.open(url, options: [:]) }
}
}
return true
}

正在打开应用程序,但未调用方法,我无法导航到应用程序内的适当屏幕。

最佳答案

好的,我发现你必须做这样的事情

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
   
    if let userActivity = connectionOptions.userActivities.first {
      self.scene(scene, continue: userActivity)
    }
  }

关于iOS 13 > 当应用程序被杀死且不在后台时,通用应用程序链接不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60524108/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com