Get geolocation when app not in use

How can we achieve to fetch user GPS location when app not in use?


Please help.

Replies

Not in use, do you mean run in background ?


Hace you set "Always Allow" for location tracking.


Note: IOS13 will change the way this works.

May read this: h ttps://www.macrumors.com

"Apple in iOS 13 made changes to the way location tracking permissions work, and there's no longer an option for apps to ask to "Always Allow" location tracking.

Instead, Apple allows users to select "Allow While Using the App," "Allow Once," or "Don't Allow,""

Hi thanks for your reply.


Not in use -> when user has closed the app, after that fetch user GPS location.

There are some Location Services API that allows an application to be launched in the background as a result of a location event, as part of iOS 13 your application will need to use one of these APIs and has the "Always" authorization by the user.


Location Services APIs that allows an app to be launched in the background:
https://developer.apple.com/documentation/corelocation/getting_the_user_s_location/using_the_significant-change_location_servicehttps://developer.apple.com/documentation/corelocation/cllocationmanager/1423531-startmonitoringsignificantlocati

https://developer.apple.com/documentation/corelocation/getting_the_user_s_location/using_the_significant-change_location_service
https://developer.apple.com/documentation/corelocation/getting_the_user_s_location/using_the_visits_location_service


https://developer.apple.com/documentation/corelocation/monitoring_the_user_s_proximity_to_geographic_regions


You can take a look and see which one fits better for your use case.