简体   繁体   中英

iOS 10 update location when app is terminated

I'm making an app where I am showing the User's distance from other users. I'm able to update user locations when app is open and when app is in background HOWEVER I can not figure out how to update the location when app is terminated. I have been told that this is not possible but I believe it is possible because Life 360, Facebook, etc update the location in terminated state. Any help on how to achieve this is greatly appreciated!

To do this you need to use:

myLocationManager.startMonitoringSignificantLocationChanges()

From the docs:

" If you start this service and your app is subsequently terminated, the system automatically relaunches the app into the background if a new event arrives. "

Unfortunately from extensive testing the significant changes when they start to come through are very inaccurate so you may wish to switch on normal location updates at the point you receive a significant location change in the background.

myLocationManager.startUpdatingLocation()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM