1

This is more of a general question although if you anyone has starting points (code wise) I'd appreciate it. This is my scenario. My app is launched and running in the background. The phone goes to sleep, is then woken up, unlocked and at this point I'd like the app to detect this. The challenges I see are as follows:

  • How to keep the app running in the background (I've read what types of apps can do this and I'm not sure my app would fit under any of those)
  • How to listen for and be ready for your app to do something AFTER the phone is unlocked (via swipe or (PIN or touch ID)).
  • Can this be done safely to fit within the Apple guidelines of acceptable apps?

Input is appreciated. Thanks all

mseg
  • 63
  • 1
  • 6
  • This is the best technique for determining whether the device is locked or unlocked - http://stackoverflow.com/questions/27933666/finding-out-if-the-device-is-locked-from-a-notification-widget by attempting to access a protected file. – Paulw11 Dec 31 '15 at 01:37
  • @Paulw11 Thanks will take a look. – mseg Dec 31 '15 at 15:39

2 Answers2

1

First check the app background modes here:

https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

Once the app is launched in the background for a period of time, and the device is secured with a passcode,

the UIApplicationDelegate method

- (void)applicationProtectedDataDidBecomeAvailable:(UIApplication *)application

will be called once the device is unlocked.

meim
  • 740
  • 4
  • 7
0

If you don't fit the list of apps permitted to run in the background then, no, you can't run in the background and expect your app to be permitted.

However, for academic interest: some sites alleged that Facebook hacked around the problem by claiming to be an audio provider and piping out silence.

I'm not aware of a means to detect phone locking and unlocking. You might be able to do something dodgy by checking out the precision of timers but that's pure speculation.

Tommy
  • 99,986
  • 12
  • 185
  • 204
  • Thanks Tommy. I feel there's still more info on this topic. I'm even curious how I could do this for my own phone (even if it wouldn't be accepted by Apple). – mseg Dec 30 '15 at 22:40