1

I am building an app for a delivery company where the vehicle drivers phones need to be notified when they are assigned new tasks(immediately), only if the task meets specific criteria.(so putting a long sound file in the push notification is not a solution)

I am able to process the task and generate a long(29s) notifying sound if the app is in the foreground or background by processing the push notification in application(application: UIApplication, didReceiveRemoteNotification userIno: [NSObject: AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)

However, this method is not called if the phone's screen is locked. Is there any way of processing received tasks when the phone screen is locked, without the user unlocking the screen?

Dylan Colaco
  • 325
  • 2
  • 11
  • NO, you can't. The method `didReceiveRemoteNotification` only gets called when app is in foreground, when screen is locked it is in background, so it won't work. – iphonic Jun 27 '16 at 10:53
  • Why do you think this method is not called if the device is locked? Are you including `content-available: 1` in your payload? – Avi Jun 27 '16 at 10:53
  • check the below link https://stackoverflow.com/questions/38007027/how-to-detect-remote-notification-in-didfinishlaunchingwithoption-application-me/38007927#38007927 – HariKrishnan.P Jun 27 '16 at 11:17
  • Thanks Avi, it seems that with content-available: 1 it does get called – Dylan Colaco Jun 28 '16 at 17:23

0 Answers0