swift - iOS re-launch in background task not accomplished -


i'm facing issue location (clvisit) when app killed. i've requested location, , seems work great when test it.

i have coredata objects creation (with magicalrecord) in didvisit delegate method, creation working when debug (app foreground or background), same when add local notification in delegate , test app killed, doesn't work when remove notifications.

i tried disable automatictermination , suddentermination doesn't work.

here sample of code in didvisit function :

func locationmanager(_ manager: cllocationmanager, didvisit visit: clvisit) {     let activity = processinfo.processinfo.beginactivity(options: [.suddenterminationdisabled, .automaticterminationdisabled], reason: "saving location data")      magicalrecord.save({ (context) inuiapplication.shared.schedulelocalnotification(notification)         let newvisit = visit.mr_createentity(in: context)         if let newvisit = newvisit {             newvisit.accuracy = visit.horizontalaccuracy nsnumber?             newvisit.latitude = visit.coordinate.latitude nsnumber?             newvisit.longitude = visit.coordinate.longitude nsnumber?             newvisit.arrivaltime = visit.arrivaldate nsdate?             newvisit.departuretime = visit.departuredate nsdate?             newvisit.address = addressstring             let formatter = dateformatter()             formatter.datestyle = .medium             formatter.timestyle = .medium             newvisit.arrivaltimestring = formatter.string(from: newvisit.arrivaltime as! date)             newvisit.departuretimestring = formatter.string(from: newvisit.departuretime as! date)         }     }, completion: { (bool, error) in         processinfo.processinfo.endactivity(activity)uiapplication.shared.schedulelocalnotification(notification)     }) } 

there's few more lines of code if statements, approximately do, create 2 entries, works same. when add notifications debug purpose in code works fine

i have questions : can problem task in delegate method didvisit long (i reduced minimum) ? why works local notifications , doesn't without them ? magicalrecord works fine , app killed , launched location trigger ?


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -