session.openApplication() -- how to pass data from the extension to the application?

Hello,

I apologize if the answer is obvious but I'm having a hard time figuring this one out.

Let's say the user taps an "Edit" button in my LockedCameraCaptureSession. The extension calls:

activity.userInfo = ["ActivityKey": "ID"]
try await session.openApplication(for: activity)

Can I retrieve, in my application, the data stored in activity.userInfo (lets say, a flag "open editor"), or is data passing exclusively handled via appContext of CameraCaptureIntent?

Thank you!

Answered by edee1337 in 808044022

For SwiftUI use:

onContinueUserActivity

and for AppDelegate use

application(application: continue: restorationHandler:)

to grab the NSUserActivityTypeLockedCameraCapture userInfo.

Hi edee1337,

You can get the data in the activity by handling the UserActivity on any receiving end in your app. The User Activity for opening the app from the capture extension will be using the static NSUserActivityTypeLockedCameraCapture activityType.

You can do this in SwiftUI via onContinueUserActivity, or via AppDelegate callbacks - try implementing the didUpdate userActivity function.

Accepted Answer

For SwiftUI use:

onContinueUserActivity

and for AppDelegate use

application(application: continue: restorationHandler:)

to grab the NSUserActivityTypeLockedCameraCapture userInfo.

Glad you got it working! I would recommend implementing the other AppDelegate callbacks as well since the entry point may differ depending on all sorts of things, including launch state.

session.openApplication() -- how to pass data from the extension to the application?
 
 
Q