iosuikitmac-catalyst

Catalyst State Restoration via SceneDelegate not working


When quitting my catalyst application via the dock icon (right click -> quit) my SceneDelegate's stateRestorationActivity(for scene: UIScene) method is called and I return a non-nil NSUserActivity.

However, when restarting my application there is no user activity in the connectionOptions of scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

Does this function correctly for anyone else? Do I need to build my UserActivity in a specific way for this to work in Catalyst? It functions correctly when running on iOS.


Solution

  • Spoke with an engineer during a WWDC2020 Lab about this. My issue, as odd as it seems, was restarting the application too soon after quitting it.

    iOS applications running on Catalyst will linger after being quit. This can be observed in Activity Monitor. It was explained that this is the period where the app can finish any registered background tasks.

    After waiting for my application to disappear from ActivityMonitor and then relaunching, it restored the activity provided in stateRestorationActivity(for scene: UIScene)