sarah
sarah

Reputation: 1221

which life cycle function should i call after going out of my app and come back

i have an app that allows the users to make a phone call, when the user click on a button on my app, i open the phone app, then the user may or may not call. in any cases, the user will (should) come back to my app, in that case, i want to do some processing. i would like to know which function suites my need the best.

as i read in other ansewrs, sounds like i have to:

  1. Save an indicator when the user open my app using the view did load function
  2. on the view will appear, i check if the user alrady saved that indicator, that means this is not the first time he visit this page and he has (should have) alreayd opened the phone app

but i am not sure

i need your help to prove my think

thanks

Upvotes: 0

Views: 761

Answers (2)

sunshinejr
sunshinejr

Reputation: 4854

AppDelegate methods are of course the reasonable choice, but with the methods, I would suggest using:

  • applicationWillResignActive() as the method before you enter from your app to multitasking window OR to the background. applicationWillEnterForeground() will only fire up when you will hit the background, but won't take the multitasking fraction with you.
  • applicationDidBecomeActive() as the method when you come back from multitasking OR background. Same reason as before.

Upvotes: 1

Oskar Gargas
Oskar Gargas

Reputation: 95

You should use application lifecycle functions from your AppDelegate to notify your controllers instead relying directly on view controller lifecycle.

Appropriate methods:

applicationDidEnterBackground: - called just after your app goes to the background applicationWillEnterForeground: - called just before it will go foreground again (it will be called on app launch too so this is a place which you should double check!)

Upvotes: 0

Related Questions