How to get the state of share extension in iOS?

306 views Asked by At

I'm developing a share extension for my app.
I know that the following methods will be fired, if user minimize and reopen the app.

- (void)applicationDidEnterBackground:(UIApplication *)application
- (void)applicationWillEnterForeground:(UIApplication *)application

I need the same thing when user minimize the share extension. The above method are not getting fired in shared extension.
I'm using UIViewController as super class of my share extension. Tried the following methods.

- (void)viewDidAppear:(BOOL)animated
- (void)viewDidDisappear:(BOOL)animated

-viewDidDisappear is not getting called when user minmize the app.

Is it possible to know if user minimize the shared extension?

I need your valuable suggestions.
Thanks in advance

1

There are 1 answers

0
paulrehkugler On

You have to call -[NSExtensionContext completeRequestReturningItems:completionHandler:] to return control to the host application. Use that as an opportunity to know your share extension is being dismissed.