zxplod
zxplod

Reputation: 59

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!

Upvotes: 3

Views: 866

Answers (1)

Damo
Damo

Reputation: 12900

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()

Upvotes: 0

Related Questions