0

I'm developing an application for iOS and i need to be able to detect when an app really closes and not when he go to background..

I already try to catch the signal SIGKILL with signal function but signal handler never has been called.. I'm using push notifications and i have to register the device in the server for the server send notifications to him when application starts (and that its possible) but i have to unregister the device when the device quit the application and not when the device have the application in background..What i can do for doing this?

Regards

mistic
  • 56
  • 2
  • 10
  • 1
    have you tried it with `- (void)applicationWillTerminate:(UIApplication *)application` in appDelegate already? :) – geo May 23 '13 at 15:03
  • Yes i've tried that and the applicationWillTerminate isnt called because this application is running only in multitasking devices and due to the apple documentation in multitask devices this callback isnt called in all exit situations. What i can do more? – mistic May 23 '13 at 15:07
  • if the app isn't closed by a normal close command but by a kill command, it will be hard to tell apple's sandbox that you want to handle this interrupt now ^^ – geo May 23 '13 at 15:15
  • 1
    Why do you need to unregister for Push Notifications when the app closes? One of the primary uses of Push Notifications is to provide communication to the user when the app is not running. – Ric Perrott May 23 '13 at 15:38

2 Answers2

2

If the OS kills your app for any reason, it is killed. There is no notification. You can't catch the SIGKILL signal. Look at the man page for kill.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
0

Detecting when app closes in all the cases is not reliable in iOS (nor it is in other OS). By design, you should avoid it.

Change your design and do not unregister the token from the server. In Apple Push Notification service, the app token is still valid after app is closed and you may use it to deliver a push notification when the app is not running.

OlegM
  • 106
  • 1
  • 5