Unable to get widgetConfigurationIntent from NSUserActivity

I have a simple lock screen widget that when tapped, should open a certain flow in my app. This works fine when the main app is already running, but when tapped while the app is not running, the app launches, but it doesn't open the flow I want it to.

When I debug it (see flow below), it seems that the problem come from the widgetConfigurationIntent(of:) function on NSUserActivity. When the app is cold launched, I get the expected NSUserActitivity, but the function above returns nil. That same piece of code returns a valid WidgetConfigurationIntent if the app is already running.

Any ideas what might go wrong? There's nothing in the documentation hinting about why this might happen, so I feel a bit lost.

BTW, this is how a debug opening from scratch with a lock screen widget:

  • Select "Wait for the executable to be launched" in the scheme editor in Xcode.
  • Make sure the app is not running on device or simulator
  • Start debugging session in Xcode (app is built but not opened)
  • Lock device, tap already installed lock screen widget.
  • App launches and my breakpoint is hit.
Unable to get widgetConfigurationIntent from NSUserActivity
 
 
Q