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

- 5,926
- 9
- 53
- 91
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.

- 331
- 1
- 13
-
Ah ok so maybe it's only used in the case that your extension uses a share sheet? – Marty Oct 18 '18 at 07:16
-
I would say: seems `returnedItems` are used by host app in case that your extension launched by host app via share sheet. Is this case _only_ or there are some other cases - I don't know. Apple [describes](https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/) about 19 extension types for iOS. May be extension launching classes for extensions of some other types have callbacks for `returnedItems` too. – Artem Oct 18 '18 at 10:39