简体   繁体   中英

Application close notification in iphone when press home button twice

In iphone it when we press home button, application goes into the background. And then when we press home button twice we can see list of running applications. And then when we press that icon for long time one red round button comes, through which we can delete the app.

I wanted to know is there any notification comes for this particular situation in iphone.

Actually i wanted to handle this situation in my code, when we are closing our application by pressing home button twice.

Please tell me some solution and please let me know it there is any clarifications required regarding this question.

Thanks

According to this question , when a user kills an app, it's a SIGKILL (as opposed to when iOS kills the app, which calls applicationWillTerminate).

You cannot execute code for when a user kills the app, only for some general application states, such as active, background, suspended, and inactive. Check out Apple's documentation on app states.

You should not (and can not) handle this specifically, because when the user double presses the home key and kills your app, that is what the user intends to do - he wants to kill your app.

The most common reasons for doing this is because there is a problem with your app. Another reason could be that the user tries to cheat your app somehow (for example in a game), so the strategy I would recommend for you is:

  1. Build your app well, so the user will not terminate it because of problems =)
  2. Save your application data and application state in
    the "applicationWillEnterBackground" event. This way you are
    guaranteed that the user will not loose any data if he/she closes the app (in a normal manner)
  3. If you think the user will try to "cheat" your app, save your application data in critical moments while the app is running. For example if you are making a game and the player fails a mission, save the app state immediately so that the player cannot cheat by killing the app.

When you double tap on the home button the list of apps shown is not al list of apps running. But a list of apps started. Sorted by the app that was start last. That the app is in this list does not mean that it is running.

When you kill an app here your app does not receive any notification that it is about to be killed. Your apps is thus not closed but killed.

iOS might kill your app when it background if the system needs to free memory. Again your app will not be notified in any way. ( but this time it will stay in de list that popsup when you double tap the home button )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM