System Events issue

Hi there!

I have the following problem:

I have a iOS game where the following needs to happen:

1) When the user gets a phone call the app should suspend, so that after the phone call he can pick up the game where he left it.
2) When the user presses the home button (to 'exit' the game) and later relaunches the game, it should start from the main menu (and NOT from the point where the user left the game).

Now, for facebook single-sign-on I need to set UIapplicationExitsOnSuspend = false, and this creates all kinds of problems. First of all, when the user presses the home button, the app doesn't exit. Using os.exit() doesn't do anything so that doesn't work to get the app to relaunch in the main menu after quitting it - you keep ending up in mid-game which sucks.

To make matters worse, the system event "ApplicationExits" doesn't register anymore when pressing the home button on iOS, so there's no way I can detect for that and make my game jump to the main menu in my code.

This is very frustrating. It seems only natural, and it is like this in 95 percent of games, that pressing the home button 'quits' the app, meaning that relaunching will take you to the home screen, but this seems impossible when you set "UIApplicationExitsOnSuspend = false". Well, you can write code that goes to the main menu on suspend, but then again that's what I don't want: suspend should leave the user in mid-game (so he can pick up where he left after a phone call) while the home buttons should quit, or do something that looks like the app ended (meaning that upon relaunch the app starts freshly from the main menu).

Any perspective on this? I'd hate to ditch single-sign-on for facebook just because there is no way to detect a home button press then.

This is how iOS4+ works.
No matter if you get a call or press the home button, the same thing will happen:
Your app will suspend to the background.
That's the way it should work. Just because a user presses the Home button doesn't necessarily mean that the user wants to quit the app.

An easy solution to your problem would be to catch the Resume event and just display a native popup asking the user "Resume game" or "Start new". That way the user can decide instead of the app forcing the decision.

Wow... So no way to determine wether the exiting of the app is intentional or because of external circumstances like a phone call? That seems to be pretty relevant information which is lost.

Your suggestion is feasible, true, but to be honest it feels annoying to me as a user to have to do this extra step for a simple game. I'll probably just call up the pause menu then, on suspend.

Regarding your comment about how OS4+ works, I can agree completely, because if you set UIApplicationExitsOnSuspend it works differently. It's a pity this is a on-off situation without an intermediate solution for the purpose I'm describing.

Thanks for the help though!

Thomas

views:1479 update:2012/1/4 9:12:54
corona forums © 2003-2011