PDA

View Full Version : Text message notification and saving data




Labeno
Apr 21, 2009, 01:03 PM
If a text comes in and the user switches over to the SMS app, then my app does not store any data (i.e. I don't think a call to applicationWillTerminate is made, which is the function that stores the data). I've read the iPhone document that states applicationWillTerminate is called any time the app exits, but this does not seem to be the case.

Anyone else out there experiencing the same issue?



fishkorp
Apr 21, 2009, 01:14 PM
I think you need to use applicationWillResignActive instead of applicationWillTerminate when being interrupted by SMS/phone call.

Labeno
Apr 21, 2009, 01:43 PM
I think you need to use applicationWillResignActive instead of applicationWillTerminate when being interrupted by SMS/phone call.

The documentation advises to use applicationWillResignActive to do things like pause if it's a game to give the user a chance to respond to the alert. Then if the user does respond, then applicationWillTerminate will still be called.

Apple may have not written the document correctly, and I have not tried this, so I will give it a go and test it. Thanks for the advice.

dejo
Apr 21, 2009, 01:45 PM
I've read the iPhone document that states applicationWillTerminate is called any time the app exits, but this does not seem to be the case.
You're sure about this? You've put an NSLog or a breakpoint into that method and are certain it is not being called?

Labeno
Apr 21, 2009, 02:13 PM
You're sure about this? You've put an NSLog or a breakpoint into that method and are certain it is not being called?

I thought I checked on this, but I will verify shortly.

fishkorp
Apr 21, 2009, 02:48 PM
The documentation advises to use applicationWillResignActive to do things like pause if it's a game to give the user a chance to respond to the alert. Then if the user does respond, then applicationWillTerminate will still be called.

Apple may have not written the document correctly, and I have not tried this, so I will give it a go and test it. Thanks for the advice.

Yep, you're right. I was thinking about that situation. I apologize.