scene(_:continue:) not invoked

Hi all, I recently migrated our app from AppDelegate to SceneDelegate in order to make it available on visionOS.

So far it is working, but I have a problem with Universal links not being invoked.

I implemented:

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

in my Scene Delegate, but it doesn't get invoked after the system opens the app.

This only happens, if the app is running in the background. If the app is not running and is launched by the OS, I receive the URL as expected in:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

If I also implement:

func scene(_ scene: UIScene, willContinueUserActivityWithType userActivityType: String)

it will be invoked by the OS, but after willContinueUserActivityWithType was called, neither:

func scene(_ scene: UIScene, didFailToContinueUserActivityWithType userActivityType: String, error: any Error)

nor:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

are being invoked by the OS.

I made a simple Barebones project with the same Bundle ID and the same Entitlements and there:

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

is being invoked as expected, upon tapping on the Universal Link in another app.

What might be the difference between the two projects causing this behaviour?

It is a rather big and old app, so it is difficult for me to compare the simple example project to the real project.

Does anybody know, where I could start to debug?

Many thanks in advance!

Answered by sfalex in 794431022

Answering my own question here just in case someone reads this with the same problem. In my case the problem was, that I was not aware, that a collegue of mine not only converted from AppDelegate to SceneDelegate, but also converted the app to a SwiftUI app. DUH!

In case of a SwiftUI App the deeplink will be sent to the  swiftUI view in the WindowGroup, inside the body of the SwiftUI.App!

So just adding an onOpenURL() modifier is enough to receive the deeplink event, when the app is running in the background.

Case closed. :-)

Accepted Answer

Answering my own question here just in case someone reads this with the same problem. In my case the problem was, that I was not aware, that a collegue of mine not only converted from AppDelegate to SceneDelegate, but also converted the app to a SwiftUI app. DUH!

In case of a SwiftUI App the deeplink will be sent to the  swiftUI view in the WindowGroup, inside the body of the SwiftUI.App!

So just adding an onOpenURL() modifier is enough to receive the deeplink event, when the app is running in the background.

Case closed. :-)

scene(_:continue:) not invoked
 
 
Q