0

Is it possible to notify an app (inactive OR active but in background) when screen is locked / unlocked?

Something like: https://stackoverflow.com/a/3617552/1011125

Community
  • 1
  • 1
filou
  • 1,609
  • 5
  • 26
  • 53
  • 1
    Why would you need this? Apple doesn't seem to allow this kind of programming, except in a push model. See http://stackoverflow.com/q/9314869 – Robert Harvey May 20 '13 at 21:52
  • I don't want to keep the application active for a background thread. I just want it to get notified when the screen is locked or unlocked, like a local notification. If it has to stay active, then it is prohibited, I know. – filou May 20 '13 at 21:56
  • Possibly related: http://stackoverflow.com/questions/7888490/ and http://stackoverflow.com/questions/704789 – Robert Harvey May 20 '13 at 22:00

1 Answers1

2

When the screen is locked, your app gets these delegate messages:

  • applicationWillResignActive:

  • applicationDidEnterBackground:

However, you cannot distinguish this situation from any other situation in which you might get those messages (e.g., the user clicked the Home button to suspend your app).

matt
  • 515,959
  • 87
  • 875
  • 1,141