n179911 n179911 - 1 month ago 5x
iOS Question

onResume/onPause on iOS application

On Android, when I write an application, I need to implement onResume/onPause for my activity to go to background and come back from foreground. I have googled if I need how to to the same thing for iOS. But I can't find anything useful. Can you please tell me what do I need to do to handle my iOS app going to background and coming back to foreground?

Thank you.


There is a dedicated class that receives delegate callbacks (from the application instance itself) for these events usually called XXXApplicationDelegate.

There you need to implement delegate methods for the application lifecycle.

- (void)applicationWillResignActive:(UIApplication *)application {

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

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

- (void)applicationDidBecomeActive:(UIApplication *)application {

- (void)applicationWillTerminate:(UIApplication *)application {