ios - How to start GPS tracking using push notification -


i'm sending push notification @ 8am start gps in application running in background. push notification receiving, gps not started tracking. how can achieve this? m using following code.

func application(application: uiapplication,     didreceiveremotenotification userinfo: [nsobject : anyobject],     fetchcompletionhandler completionhandler: (uibackgroundfetchresult) -> void) {      nslog("userinfocomp %@",userinfo);      var app = uiapplication.sharedapplication()         var  bgtask2 : uibackgroundtaskidentifier?      bgtask2  = app.beginbackgroundtaskwithexpirationhandler { () -> void in         app.endbackgroundtask(bgtask2!)         bgtask2 = uibackgroundtaskinvalid     }     if bgtask2 == uibackgroundtaskinvalid {         return     }      pslocationmanager.sharedlocationmanager().preplocationupdates()     pslocationmanager.sharedlocationmanager().startlocationupdates() } 

you can not start location service when app in background mode. need use startmonitoringsignificantlocationchanges when app active user's permission (to track him if user not using app) location update in background mode.

you location update when app terminated user @ every 5 min if user not stationary.

if app in background may location update using startlocationupdates it's not reliable if 3-4 apps in background os may stop updating location.


Comments