Alex
Alex

Reputation: 11137

what method in my AppDelegate.m is executed when an app is relaunched from background?

I have an app that has a local database and i wish to call a function when the app is called from background(i.e. when i recall it from the 'task manager') so that i may update my database from a web service. What is the method called and can i get it to execute in my app's delegate?

Upvotes: 0

Views: 307

Answers (2)

Vladimir
Vladimir

Reputation: 170829

Check applicationWillEnterForeground: and applicationDidBecomeActive methods in UIApplicationDelegate.

applicationWillEnterForeground

In iOS 4.0 and later, this method is called as part of the transition from the background to the active state. You can use this method to undo many of the changes you made to your application upon entering the background. The call to this method is invariably followed by a call to the applicationDidBecomeActive: method, which then moves the application from the inactive to the active state.

Upvotes: 3

Saurabh Passolia
Saurabh Passolia

Reputation: 8109

applicationWillEnterForeground & applicationDidBecomeActive method/delegate is called when application is restored from background.

However, you should keep this provision (i may update my database from a web service) in applicaitonDidFinishedLaunching as well because you dont know if OS have terminated your background application (which OS can certainly do upon his discretion if your app does not have proper background processing permissions) application and OS may launch the application as fresh launch rather than restoring from background.

Upvotes: 0

Related Questions