Can I send the user's current location to the server when the application is in the background?

Is it possible to send the user's current location to the server when the application is in the background. For example: In my application, I want to save the user's current location every 2 minutes, and then send their current location to the server. Can I do this when the application is in the background? Can I send location updates to the server in the background and how?

+4
source share
3 answers

You can with iOS7. You basically need to set two background states: location and selection.
 In your application, you register for gps location changes and store them every time you call a callback. You will then register for:

 application:performFetchWithCompletionHandler:

This is usually used to upload files in the background, but you can use it to send your data to a web server. Just note that you do not control the frequency of this call.
To verify this, you can force the fetch operation in the iOS simulator from the Xcode Debug menu.
Thus, I was able to correctly track the user's position. You can find more information in the Apple doc and you will find the background sample tutorial here

+6

, ios ( Android, Windows java me). . Google. MIT. , :

https://github.com/nickfox/GpsTracker

, phoneClients ios, , . ios AFNetworking, - .

+1

Source: https://habr.com/ru/post/1524938/


All Articles