Where does a host app handle NSExtensionContext#completeRequest?

柔情痞子 提交于 2019-12-22 05:43:12

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/52699306/where-does-a-host-app-handle-nsextensioncontextcompleterequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!