简体   繁体   中英

Update Location when app is terminated

i am working on an app that uses location of the user to send him matched users even if the app is terminated or swiped out from the running apps in iOS. Is there any way that i can call an api to upload the current location of the user if he moves 50 Feet away from his current location or not? I have read that apple does not allow code to be executed if the app is in background or terminated. So please suggest me what should i do and how should i do it stepwise so that i can accomplish this task and this may help me in many of my apps surely.

In a word, no. You could subscribe to significant location change notifications. Then when the system detects that the user has moved by "a significant distance" (defined by the system.) I'm not sure what the system calls a significant location change, but it's going to be a lot more than 50 feet.

Another alternative would be to create a geofence around the user's current location and listen for location updates using the Core Location startMonitoring(for:) function.

Both of those techniques will relaunch your app if they detect a relevant event and your app isn't running.

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