targetContentIdentifier on NSUserActivity nil on Handoff

I am using scenes and setting up Handoff between a Mac and iPad/iOS application. Whenever I receive the user activity on the iPad, targetContentIdentifier is always nil. I've confirmed that things like userInfo and persistentIdentifier are coming through by outputting them in func scene(_ scene: UIScene, continue userActivity: NSUserActivity), but without the targetContentIdentifier is always empty. Without it, I can't use the activation condition's and proper scene isn't being selected by iOS... is there something beyond setting it and marking an activity as eligible for handoff that I am missing?

Replies

I can observe the same effect when restoring scenes after app being closed (by user or through crash) on iPad simulator, iOS 15.5. Scenario is as follows:

  1. Start new scene with activity containing targetContentIdentifier
  2. Send scene to background -> stateRestorationActivity(for:) is called, where activity scene was started with is returned (targetContentIdentifier is still there).
  3. App crashes
  4. App is restarted, but activity received in scene(:willConnectTo:options:) does not have anymore targetContentIdentifier in session.stateRestorationActivity.

Can anyone comment on that - is this correct behaviour or is this a bug?

  • I believe it’s probably a bug - I can confirm that Apples apps have the same behavior. No word from them back on feedback assistant yet.

Add a Comment