skip to Main Content

In Swift 4 it’s working fine in all device and iOS versions.

After upgrading to swift 5 deeplink open the app, But userActivity method is not called.

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
        guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
        let url = userActivity.webpageURL
        else { return false }
        print(url)
        return true
    }

Our App support iOS 10 and above.

2

Answers


  1. Chosen as BEST ANSWER

    restorationHandler Callback type has been changed from [Any] to [UIUserActivityRestoring] then it's working fine for me.

    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
            guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
            let url = userActivity.webpageURL
            else { return false }
            print(url)
            return true
        }
    

  2. if you set the initial viewController via SceneDelegate. You need to add this to SceneDelegate

        func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
            guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
                  let url = userActivity.webpageURL else {
                      return
                  }
            print(url)
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search