Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does a host app handle NSExtensionContext#completeRequest?

When you call completeRequest(returningItems:completionHandler:) from an extension, where does this get handled by the host app?

like image 374
Marty Avatar asked Oct 08 '18 09:10

Marty


People also ask

How do app extensions work?

In a typical request/response transaction, the system opens an app extension on behalf of a host app, conveying data in an extension context provided by the host. The extension displays a user interface, performs some work, and, if appropriate for the extension's purpose, returns data to the host.

What is an app extension?

App extensions allow you to link to your mobile or tablet app in your text ads.

What is an action extension?

An Action extension helps users view or transform content originating in a host app. For example, an Action extension might help users edit an image in a document that they're viewing in a text editor.


1 Answers

Disclaimer: did not checked my assumptions, but may be this helps.

1) documentation states:

Call the completeRequestReturningItems:completionHandler: method, which signals the host app that its original request is complete

2) here - Figure 2-3 shows that "Host"-app - is app that starts some work with extension. For example, "Host" may be the app in which user touches "Share"-button. Then this "Host"-app sends some data (which user wants to share) to extension.

3) "Sharing data"-extension, I think, very common example of extension. So very probable that somewhere in UIActivityViewController must be way to realise completeRequest(returningItems:completionHandler:) that you looking for and that called from extension. And this is what I found:

@property(nullable, nonatomic, copy) UIActivityViewControllerCompletionWithItemsHandler completionWithItemsHandler NS_AVAILABLE_IOS(8_0); // set to nil after call

documentation says about this property:

Upon the completion of an activity, or the dismissal of the activity view controller, the view controller’s completion block is executed.

and:

returnedItems - An array of NSExtensionItem objects containing any modified data. Use the items in this array to get any changes made to the original data by an extension

Again, I did not test it. But this property looks like handler you looks for.

like image 94
Artem Avatar answered Sep 24 '22 17:09

Artem