简体   繁体   中英

How to get the state of share extension in iOS?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM