Alexey Alexey - 1 year ago 73
iOS Question

Listen for application terminate from a library/framework?

Is it possible to listen for the iOS application terminate/going to background mode from a library/framework, which is included into that app?

As I see,

method (for a class which implemented in the library) does not called in case if whole app terminating (correct me if I'm wrong).

UPD.: The question is about libraries/frameworks. I know about
method for AppDelegate, but it's for the app itself, not for a library/framework.

Answer Source

Registering for UIApplicationWillTerminateNotification via NotificationCenter will work.


    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate) name:UIApplicationWillTerminateNotification object:nil];

    //..... task to done before termination
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download