0

I'm implementing deep links in ios using universal links. From what I can see, when the app is in the background, it's working,using the sceneDelegate method

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

however, if the app is not in the background, the deep link, just opens the app without sending the information of the link. Is it possible to redirect the user to a specific place in the app using universal links or some other way if the app is not in the background, for example after a reboot or if the user killed the app?

Thanks

user2679041
  • 241
  • 2
  • 13
  • Does this answer your question? [iOS Deep link callbacks not working when the app is closed](https://stackoverflow.com/questions/66426883/ios-deep-link-callbacks-not-working-when-the-app-is-closed) – Raja Kishan Nov 13 '21 at 12:24

1 Answers1

0

That delegate method will only be triggered when the user is the app is in the background, in order to make universal links work when the app is killed you need to trigger the willConnectTo delegate method:

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let userActivity = connectionOptions.userActivities.first,
              userActivity.activityType == NSUserActivityTypeBrowsingWeb,
              let url = userActivity.webpageURL?.absoluteString else {
                  return
              }
        handleUniversalLink(url: url, scene: scene)
    }
mdmcc
  • 1
  • 1