Periodic iOS background location updates

前端 未结 9 1440
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 14:56

I\'m writing an application that requires background location updates with high accuracy and low frequency. The solution seems to be a background NSTimer t

9条回答
  •  轮回少年
    2020-11-22 15:37

    When it is time to start location service and stop background task, background task should be stopped with a delay (1 second should be enough). Otherwise location service wont start. Also Location Service should be left ON for a couple of seconds (e.g. 3 seconds).

    There is a cocoapod APScheduledLocationManager that allows to get background location updates every n seconds with desired location accuracy.

    let manager = APScheduledLocationManager(delegate: self)
    manager.startUpdatingLocation(interval: 170, acceptableLocationAccuracy: 100)
    

    The repository also contains an example app written in Swift 3.

提交回复
热议问题