How does my app know when iOS calls completionHandler of completeRequest(returningItems:completionHandler:)?

In this documentation for completeRequest(returningItems:completionHandler:), there is a box shaded yellow that says:

Important If the system calls your block with an expired value of true, you must immediately suspend your app extension. If you fail to do this, the system terminates your extension’s process.

How does my app or my Share Extension know when the system calls the block spoken of?

  • Completion handler is dispatched to a queue. You don't know exactly when this queue will get executed.

Add a Comment

Replies

The system can call your completion handler at any point. There is no way of knowing upfront when this will happen. You have to implement the completion handler and react accordingly in there.