-2

Apologies if this question has already been asked but during my search of stackoverflow i could not find an exact answer to this question.

Is there any allowed way that my app can make a network request as soon as the iOS device is unlocked ?

All of the methods describe to listen to unlock notification involve com.apple.springboard.lockcomplete which is not really allowed by apple. Is there any other possible way ?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
dev_ios999
  • 339
  • 3
  • 9
  • 1
    no, apple has its own process for handling background tasks. You should read up on all the available background modes, background-fetch etc. Non of these support that – Simon McLoughlin Sep 13 '19 at 13:22
  • I know that is the problem. Background-fetch etc will not tell me when the device is unlocked and i only want to send the request as soon as the device is unlocked. – dev_ios999 Sep 13 '19 at 13:26
  • 1
    I understand, thats why I said in my comment that its not possible and these modes don't support that. Tracking when a user unlocks there phone outside your app also sounds like something you shouldn't be doing and I wouldn't install an app that did such a thing. Its invasive to track things outside the app, and apple make this impossible or extremely difficult by sandboxing all apps – Simon McLoughlin Sep 13 '19 at 13:33
  • There should have been a close vote option for questions try to exploit security vulnerabilities. – Desdenova Sep 13 '19 at 14:16
  • Well the app doesn't have any malicious intention but you are right it could be thought of as such. – dev_ios999 Sep 13 '19 at 14:17

1 Answers1

0

If you initialize your Network Manager class (like Alamofire.Manager) In applicationWillEnterForeground of AppDelegate it should work fine.

kweselski
  • 1
  • 1
  • Yeah but i don't want to send the request in `applicationWillEnterForeground`. That will only work when the user will tap on my app. What i want is that whenever the user unlocks the device regardless of whether he opens my app or not. My app should be able to send a network request. – dev_ios999 Sep 13 '19 at 13:25