Location Tracking - iphone

I have application which is sending tracked data to our hosted server whenever location manager called in background. Its working fine normally.
But issue is when user switched off the iPhone and turn ON it back application is showing GPS icon but application is not giving response.
PS: User have not touch the app or start after restart the app.
Is it possible to get the response from the app after restart the device?

That is because the app is not active after restarting the iPhone. You could add the voip key to UIBackgroundModes as detailed in this SO post (and a sample app on GitHub) to start your app again after restarting the device. However, if you use this app only for tracking the location, Apple will likely reject your submission for making use of the voip-key.

If you use region monitoring, then your app will be automatically started in the background when a user enters or leaves a region, even if the device is turned off and back on. Use region monitoring, see this answer on SO.

Related

Application doesn't launch with location key after a significant location change

My application uses the core location also after the application terminates with the method startMonitoringSignificantLocationChanges in CLLocationManager class.
My application launches with a location key in iOS 5 and 6 in the method:
- (BOOL) application:application didFinishLaunchingWithOptions:launchOptions;
in AppDelegate class and everything works well.
But in iOS-7 betas the application doesn't launch with a location key after a significant location change.
Has anybody encountered this problem?
I tried it on a simulator and in the device.
Thanks for the help.
I have the same problem in my app, when the app was terminated by user from app switcher.
But it does launch with location key if it was terminated by OS for low memory or other reason.
It is the expected result from iOS7 unfortunately. An official apple response I got from one of their evangelists:
If a user swipes up in the app switcher then the OS will not launch
the app unless explicitly told to do so by the user. So no, SLC will
not be launching the app, nor will silent notifications. The only
thing that will launch the app at that point is the user tapping the
icon. The intention here is that the user has expressed their choice
of not having that app running any more for any reason, so we honor
that. In this situation, there's really nothing that you can do. The
next time the user launches the app you can let them know that some of
the data may be missing, although you really cannot tell whether
there's missing data or not (i.e. you might have been killed by the OS
in the background and the user may not have moved thereby not
triggering any SLC notifications). My suggestion would be to gather
the data you can within the policies of the OS and if the user has
manually killed the app then respect that wish and don't do anything.
By all means, feel free to file a bug report if this change in
behavior winds up causing problems for you or (especially) confusion
for your users.
Attach link to Apple DEV forums:
https://devforums.apple.com/message/882691#882691

How to receive acceleration-related data from the onboard hardware, when application in background mode?

Am developing application for calculate count of user moved steps and draw the user activities in the map. And we are using UIAccelerometer delegate for receive acceleration-related data from the onboard hardware. So I need to receive acceleration-related data when the application in background mode too. Last time one of my application got rejected because of using location service in background, Apple suggested me like "you can only use this background mode if your app truly needs this information to provide value for the user". Kindly suggest the best approach for this application.
You cannot run accelerometer in background.
You can track user's location in background... however, if you just keep tracking it and do nothing with that info.. apple is going to reject it and tell you to just get the lates location when app comes to foreground.
what you can try is.. update the user of total distance covered etc on a regular basis (like run keeper) and this will justify tracking location in background.
But first, you can try appealing to the review board explaining that you need to track location in background because you show entire route travelled by user when app comes to foregraound. and compare this to existing apps like run keeper and if you are lucky apple may approve your application without any changes...
This can easily be done.
What happens in that iOS put your application in halt state when your application is not in running in foreground state.
You just need to register your application for background execution.
Refer :
http://dcraziee.wordpress.com/2013/05/20/background_ios/
Also refer :
iOS background application network access
for apple policies about using location service.Which states that you can use location service in background.

can i get location with GPS while my application is closed?

I've seen application on iphone called "moves"
the gps is running on background while the application is totaly closed and not working in the background.
how can i get the location of the user and send it to the application while it is closed and not working on background? how could this possible?
what is the function to do that?
thanks
It is possible to get the location while the phone is running in the background (The Google Maps app does this), however running a background thread is a privilege that you must justify to Apple in their review process.
Here is some documentation by Apple for guidelines for running in the background
You register for the significant-change location service.
According to the Apple docs:
If the app starts this service and is then terminated, the system relaunches the app automatically when a new location becomes available.
This is not possible for an App on a non jailbraked iphone. Check again what you really have seen.
Apps can run in the background and get locations. But an app which is closed, can not do anything, since it is not running.
Maybe you have sawn the GPS Arrow in the status bar, staying active. But this disappears after some seconds, as long as no other application uses GPS.

Will an iOS app that monitors signficant location changes be restarted on device reboot?

From the Core Location documentation:
The regions you register with the location manager persist between launches of
your application. If a region crossing occurs while your application is not
running, the system automatically wakes up your application (or relaunches it)
in the background so that it can process the event. When relaunched, all of
the regions you configured previously are made available in the
monitoredRegions property of any location manager objects you create.
Unfortunately, this is unclear as to whether or not the same app will also be relaunched after device reboot in response to a region change.
Will an iOS app that monitors significant location changes in the background still be relaunched, even after a device reboot?
Yes, your app will be launched to respond to the region events even if the phone is restarted, and even if the user did not explicitly run your app after the reboot.
I haven't seen any documentation that spells that out clearly. But this is how it works in a couple of my own apps.
Just to make an update. I know that this is an old question, but I want to confirm that it works on iOS7, even after a reboot.
Check my question here:
Are background mode location and fetch called even after the device restarted in iOS7?

Load the iphone app automatically when phone boots

I am doing a tracking kind of application for internal use of an organization and do not wish to submit it to app store.
What I am doing in the application is I am tracking the phone calls, messages etc.
My app runs in background once I start the app manually and keeps on running in the background until I close the app or the phone is switched off.
The thing that I want to add to my app is, I want to load the app automatically when the phone is switched on again.
Any idea or guidance will help. Suggestion for use of private apis is also welcome.
In private api, in file SBApplication.h there are all methods that you need.
In particular:
[...]
-(BOOL) _shouldAutoLaunchOnBoot:(BOOL)boot;
-(void) autoLaunchIfNecessaryOnBoot:(BOOL)boot;
-(void) _cancelAutoRelaunch;
-(void) _relaunchAfterExit;
[...]
etc, etc...
hope this helps.
As far as I can understand you can do it by registering your app for significant location changes. If an app registers for significant location changes, as soon as your cellular phone moves to a new tower, app receives an update. If the application is suspended when an update occurs, the system wakes it up in the background to handle the update.
So if you close the app and turn of your phone, as soon as your phone will restart it should get an update and it will force your app to run in background mode.
For more info read iOS programming guide: http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html
Hope it helps