1

My app must sometimes show an UIAlertView when the Home button or the locking button is pushed or when the notification center is shown.

I show the Alert from the applicationWillResignActive delegate's method and everything is ok when home button is pushed or when notificacion center is shown. But there is a problem if the button which is pushed is the locking button (on/off button).

In that case, the Alert is not shown when I return to the app (if I used the Home button it is there). I don't do anything else in other AppDelegate methods which are executed. Also, then, when I show a new Alert (any Alert in the app) the Alert which hasn't been shown when I returned is shown after I dismiss the new one.

Please, could anybody help me?

Thanks in advance.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
angeleke
  • 219
  • 2
  • 10
  • 2
    You need to post some code – JSA986 Mar 31 '13 at 19:20
  • 1
    Seems strange to want to show an alert when the app has just been backgrounded - surely you won't see it. Why not show the alert when it comes back, with applicationDidBecomeActive: instead? – Lewis Gordon Mar 31 '13 at 21:31
  • Take a look at: http://stackoverflow.com/questions/4783152/how-to-differentiate-lock-screen-and-home-button-background-multitasking-on-ap – viral Apr 01 '13 at 07:20
  • Also see: http://stackoverflow.com/questions/8964026/alternatives-to-applicationdidenterbackground-and-applicationwillresignactive – viral Apr 01 '13 at 07:23
  • Yes, I could do it with applicationDidBecomeActive but I didn't understand the different behaviour with the two buttons. Thanks everybody! – angeleke Apr 01 '13 at 19:11

1 Answers1

0

THE EASY, GIVE ME REP ANSWER:

When the app is put into the background, the app is suspended. Part of this process is closing open alert views.


THE I ACTUALLY KNOW WHAT I'M TALKING ABOUT ANSWER:

The logic behind this is that when the user hits the home button when an alert is displayed, they might be going to look for information on how to answer the alert. However, when the sleep button is pressed, the user has stopped using the device altogether. Apple knows that if they unlock thier device again 3 hours later and see something like Confirm Deletion, they will have absolutely no idea what they were just doing and what to do now.

This is known to cause a serious condition known as what-in-the-world-am-I-supposed-to-do-now-itis. Symptoms of this condition include hitting the round button at the bottom of the screen and subsequently holding on your app icon until it jiggles. They then hit the little 'x' button. This is not good for developer's pockets.

Undo
  • 25,519
  • 37
  • 106
  • 129