send latitude & longitude on Server at 15 minute time interval - ios

I want to send lat and long of device on server with 15 minute time interval even my app is not running in background. Is that Possible or Not.

Background it is possible, but if you kill app then doesn't, Appstore would not allow such app. another thing it will drain device battery as well.
Enable background modes.

Related

How to kill app in background after X Amount of time

I am working on an app where I am getting an access token which would be valid for 300 seconds.
If in case app moves into the background (say phone call) for more than 300 seconds, I have to kill the app in the background.
I am able to increase the time of the app in the background using any services (Location etc) but please guide me how to kill the app in the background once token time (300 seconds) has been expired.
Have a look at this link.
https://www.raywenderlich.com/143128/background-modes-tutorial-getting-started [Section: Performing Finite-Length Tasks]
The example tells you how to get extra time to complete what you’re doing when the app gets into background.
An app can be killed using
exit(0)
This would lead to exiting the RunLoop, but it may lead to AppStore rejection.

iOS: How to use location tracking during predefined time period while saving battery life?

iOS: How to use location tracking during predefined time period while saving battery life?
I need to activate location tracking during predefined time periods (does not matter if app in background or foreground) and need to be sure that battery life is not impacted too much?
PS:
Please not that running location in background with tracking significant changes does not suits because it gives you location after 10 min and only when you passed reasonable amount of distance ... so during driving 40 km I got location only 3 times that will not allow me to catch user movement near some point. If running location more often ...that drains battery upto 40 percent per 6 hours...
I've researched all background modes in iOS very thoroughly recently.
The only deterministic way that will allow you to do that, without location background mode are silent pushes.
You send a silent push to the user and the user returns a location.
You could also use background fetch. But it's very non-deterministic. You can't predict if it indeed will wake up your app, or not.
EDIT:
Please note, that this will not wake up the app that was forcefully terminated.
However, the system does not automatically launch your app if the user
has force-quit it. In that situation, the user must relaunch your app
or restart the device before the system attempts to launch your app
automatically again.

Waking up an app from background by a time interval?

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!
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

iOS GPS Tracking app shutdown in background

I'm currently working on an iOS app using objective-C that send every minute gps coordinates to my API.
I've used AFNetworking & CoreLocation, I also wanted my App to run all day long, but only send coordinates if time is between 8am - 6pm.
Everything's working fine on iOS simulator targetting iOS9 my app is sending his location every 1 minute to my API, even if i press home or lock the phone.
PhoneCall, loss of network or GPS have been handled in order to keep my task running.
But when I tested it on some device (iPhone 4S on iOS9) Location stop updating after an average time of 1hour to 1hour and a half.
Is iOS shutting down my app in background after a given time?
If so, is there a way to keep my app doing her job in background for at least 10 hour, without having to prompt the device user?
Implementing long running background task are "allowed" by apple if it concern:
"The app keeps users informed of their location, even while it is running in the background."
Does that mean background task will block my http request after a while?
For long term deployment, I wish my app to be upload on the App Store, but I've read many post about app GPS tracking app which have been rejected.
Here's the minimal list of requirement my app should have:
Send GPS coordinates to my API every minute
Working in background for a minimum time of 10 hours without shutting down or prompting user to reload the view
Could those requirement be accepted to get my app upload on AppStore?
Or will I have to use local/remote notification and prompt the user to reload my app in order to keep it running for such a long time?
The documentation says.
The significant-change location service is highly recommended for apps that do not need high-precision location data. With this service, location updates are generated only when the user’s location changes significantly; thus, it is ideal for social apps or apps that provide the user with noncritical, location-relevant information. If the app is suspended when an update occurs, the system wakes it up in the background to handle the update. If the app starts this service and is then terminated, the system relaunches the app automatically when a new location becomes available. This service is available in iOS 4 and later, and it is available only on devices that contain a cellular radio.
I think this will be apt for your scenario.

How to tackle an app that fires recurring local notifications but on a changing schedule?

I'm creating an app that needs to fire local notifications for sunrise and sunset on a daily basis.
Sunrise and sunset times changes every day.
I want the registering of the local notifications to take place even if the user didn't open the app (i.e. a background task). So the user installs the app, sets his location (since sunrise and susnet calculations are location based) and then he knows he'll get notifications for sunrise and set every day without needing to open the app or being connected to the internet.
Ideally I need a background task for registering local notifications over a given period which runs at least once every period. "e.g. registers local notifications for the next week, which in that case I need it to run at least once a week".
None of the current background modes fit my case, I tried a background fetch, but since there're no data downloaded iOS stopped running my background task after a couple of days
I know I can use push notifications, but I don't want to unless it's my last option, cause I want the notification to take place even if the phone was not connected to the internet.
So how do you think I can tackle this? Is there something I'm missing?
Get Location for every ’n’ minutes in background. By Using beginBackgroundTaskWithExpirationHandler and NSTimer .it keeps app live in background.
So, You can schedule a localnotification in background.
For getting location update in background Refer the link
How do I get a background location update every n minutes in my iOS application?
(From iOS7 finite-length background task time reduced to 180 seconds. so you must fetch location within next 180 seconds.)
If user force quit the app. the app destroyed all the task . Use Significant location change or region monitoring to restart the Background task and get location for every ’n’ minutes.

Resources