1

While share extension view controller is being presented (visible), is there callback method that can be implemented in the extension's view controller to know when user presses home button which will cause the host app to resign active?

I have tried the following:

  • viewWillDisappear:
  • viewDidDisappear:
  • UIApplicationWillResignActiveNotification
  • UIApplicationDidEnterBackgroundNotification

None of the above works.

I need the callback so that when user closes the app, I would like to suspend all network operations that is currently running in the share extension process.

meiwin
  • 110
  • 8

1 Answers1

1

You can register for the following notifications (defined in NSExtensionContext):

  • NSExtensionHostWillEnterForegroundNotification
  • NSExtensionHostDidEnterBackgroundNotification
  • NSExtensionHostWillResignActiveNotification
  • NSExtensionHostDidBecomeActiveNotification

-viewWillDisappear:/-viewDidDisappear: only apply to the view controller used to present the share extension.

goetz
  • 916
  • 6
  • 14