onContinueUserActivity not working on first app launch

HI,

I'm trying to deeplink from my widget to a view in my app. I'm using the "SwiftUI app lifecycle".

This the code I'm currently using:

var body: some Scene {
        WindowGroup {
            RootView()
                .onContinueUserActivity("NextDeparturesWidgetConfigurationIntent") { userActivity in
                    guard let configuration: NextDeparturesWidgetConfigurationIntent = userActivity
                        .widgetConfigurationIntent(),
                        let stationEntity = configuration.stationEntity else { return }
                    NotificationCenter.default.post(name: .onOpenStation, object: stationEntity.id)
                }
        }
    }

It is working fine when the app is already running (in the background). However when the app is "cold starting" (ie. not in memory) onContinueUserActivity is never called.

I tried adding a UIApplicationDelegateAdaptor:

    func application(
        _ application: UIApplication,
        configurationForConnecting connectingSceneSession: UISceneSession,
        options: UIScene.ConnectionOptions
    ) -> UISceneConfiguration {
        if let userActivity = options.userActivities.first {
            let configuration: NextDeparturesWidgetConfigurationIntent? = userActivity.widgetConfigurationIntent()
            // casting fails
        }

        return UISceneConfiguration(
            name: nil,
            sessionRole: connectingSceneSession.role
        )
    }

I can see that the activity is received but it is never casted to NextDeparturesWidgetConfigurationIntent.

What am I missing ?

onContinueUserActivity not working on first app launch
 
 
Q