0
votes

is it possible on newest ios to make a tracking app wake up every x minutes in order to send the stored locations to an url, even if the user is not moving?

Requested functions of the app are:

  • App is getting locations based on distance filter (example: only get coordinate via gps, when user has moved more than 10 meters.

  • App is not allowed to send every new position immediately to url

  • App should store all new locations of the last 3 minutes

  • App should send stored positions (of the last 3 minutes) in an interval of 3 minutes. (! Even if user has not moved since a while, app shall connect to url.

  • App is mainly running in backround.

Example case: User has moved more than 10 meters at 9:00:11 to position 53.432, 13.245, at 9:01:20 to position 53.235, 13.435 and at 9:03:10 to position 54.002, 13.768. No more movement of more than 10 meters before 9:15:00. So from 9:00:00 until 9:15:00 device has located 3 coordinates. Order from server is: Send all locations in an interval of 3 min., starting from 9:00:00.

Requested result is: At 9:03:00 app sends all positions from 9:00:00 until 9:03:00: 9:00:11: 53.432, 13.245, 9:01:20: 53.235, 13.435

At 9:06:00 app sends all positions from 9:03:00 until 9:06:00: 9:03:10: 54.002, 13.768

At 9:09:00 app sends all positions from 9:06:00 until 9:09:00: „no new positions“....

Problem is: App has to be waken up, in order to process actions like sending informations to the server. One event, that could wake up the app would be a movement of more than 10 meters. But since user is not moving from 9:03:10 until 9:15:00, there is no event that wakes up the app. App stays suspended and will not send the location of 9:03:10 before next movement at 9:15:00

Solution? Are there other possibilities to make the app wake up and send stored locations at 9:06:00? Can apps have an internal timer to wake up?

(According to my understanding a timer app is not waking up, when the alert sound should be given. Instead it is scheduling a local notification to fire at the time of the alert.)

But if it is possible to schedule local notifications, can´t an app schedule other actions like „wake me up“?

Thanks a lot for your time and help!

1
Welcome - what code do you have so far to wake your project up? If you fire up Xcode and search the documentation for Multitasking Overview you can get a grip on the API that are available if you are looking more for documentation than specific code support. Also, key on Implementing Long-Running Tasks in background execution...bmike
Hi bmike, thanks for your answer. We have not developed the app yet. And I don´t know about the code to be used. (I hope, it was ok to post here, even though I am not a developer myself.) A friend wants to use the distance filter to wake the app. But I have doubts about his oppininon about waking the app: According to him there is only one possibility to guarantee, that app can wake and send stored locations: "Only if the gps is is running permanently the app is able to process an action like sending stored positions." This sounds strange to me.Felix Bartelt

1 Answers

1
votes

the app can attempt to run background tasks, but it can't force itself to stay in existence - the OS will shut it down after a couple of minutes, regardless of local timer handlers or notifications.

Your best bet is that as soon as the user has moved more than 10 metres, the server starts sending push notifications. You can have a handler which can wake the app in the background, and you can use this handler to send data back to the server.

There are a lot of rules regarding when to use certain background modes, so in case you haven't come across it before, check out this link.

https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html