Required Background Mode for location not re opening app after reboot - iphone

We are trying to develop an application similar to an existing app currently in the app store.
This app is sending location data in the background to a web service, and the app will continue to run following a reboot of the device. I will also note, that following the app being installed and registered, the location services indictor remains constantly on the status bar. I am assuming this is necessary to allow the app to continue to run following a the device being restarted.
We have tried using the "UIBackgroundModes/required background modes for location", and have been unsuccessful in having the app continue to run following a reboot of the device.
Can someone please point us in the right direction as to how to have the app continue to send location data following a device reboot.
Thank you very much!

No app will run following a device reboot. It is not possible to build a file daemon under Apple's SDKs. You'd have to jailbreak the phone and run unauthorized stuff to do so, then you wouldn't be accepted into Apple's app store.

Yes your app will be restarted if your are monitoring significant location changes or monitoring a region and that region is entered/exited.
In iOS 7 Apple made an important change that will disable these mechanisms if a user force quits your app. They will remain disabled until the user starts your app again.

Related

Location update stops after reboot application

Location update stops tracking after some longer period of time (few days) or after restart device. Is there any solution for this problem?
I have set "App registers for location updates" in plist file.
According to the official Apple iOS SDK automatic stating for an app is only possible for apps that declare the VOIP background mode:
VOIP
The app provides Voice-over-IP services. Apps with this key are
automatically launched after system boot so that the app can
reestablish VoIP services. Apps with this key are also allowed to play
background audio.
No other background mode specifies that the app will launched after system boot.
If you use the VOIP key and you app is not a real VOIP app you might be rejected so this might not be an option.

CLLocationManager Permissions on iOS 4.3

I currently have an application that uses location services and is working great on devices running iOS5 and above. However, have been running into inconsistency issues with 4.3.x.
Problem:
When installing and running the app for the FIRST time, we get the usual 'Allow this app to use Location Services' dialogue to change the [CLLocationManager authorizationStatus]. However, when we uninstall the application (from the home screen) and reinstall the app, we never get this prompt again and somehow the OS has cached the users response for this app, despite this app being uninstalled and reinstalled freshly. On all other versions of iOS, we get the prompt as expected and the [CLLocationManager authorizationStatus] is set to kCLAuthorizationStatusNotDetermined as expected.
Can anyone tell me why with 4.3 the OS seems to remember the options for the app despite it being uninstalled? In order to rectify this issue currently, I have to manually reset all Location Services settings on the device through the settings menu.
If you need any information, or code snippets, please ask.
It turns out this is a 4.3 limitation and is apparent when running an application on any device iOS 4.3.
Apple must have decided this isn't a bug - which is strange seeing as when a user uninstalls an application, why does the OS remember that users selection of permission for a particular app?
No valid workaround available. Just have to live with it.

Can iPhone apps start on start-up?

I've answered two different questions now, both explaining how VOIP apps don't start on start-up, yet people seem to think they do.
I'm not 100% sure myself, someone linked me to a part of the apple docs, which doesn't really mention anything about auto-starting of apps.
I was originally going on prior knowledge and this answer, but after another person saying that they do, I'm really not sure.
As far as I'm aware, apps only react to push notifications, and can't be launched into the background when a device is turned on.
Can we please clarify whether it is possible to auto-start an app or not?
Take a look at the UIBackgroundModes section in this document - it seems to state that adding the voip key will autostart an app on boot.
Edit: a sample app seems to confirm this behavior.
I confirm that setting VOIP mode works. However, I've found that the app won't restart after power up unless it was running when the device was powered off. Furthermore, the app won't actually restart on the recently powered up device until the device is unlocked after power up.
OK, I don't know if this classifies as an answer but I feel obligated to say. I am developing an app that both tracks significant location changes and provides VoIP features. The app has voip key in Required background modes. I tried some cases which I would like to share the results:
App is in Debug mode - Turned off while app was running (active or background) - iOS 7.1.1 (11D201) and iPhone 4 (product name: iPhone3,2):
When booted, app is running in background, as well as other apps that were running before. I do not think this is related to VoIP in any way.
App is in Debug mode - Turned off while app was terminated - iOS 7.1.1 (11D201) and iPhone 4 (product name: iPhone3,2):
When booted, the app is not running, there are no logs in configuration utility, server says the user is not registered I cannot call it from other devices; and yet the other apps that are not related to voip or location tracking but were open before turning off are at least loaded in memory. Meaning, the voip key did not work.
I have continued the test with the same app but this time downloaded it from app store. The results are the same. Changed the device and os to iPhone 3G (product name: iPhone2,1) and iOS 6.1.6 (10B500). Nothing changed both in debug and release modes.
I have told my boss that Apple provides this behavior and it can be done. Then I had second thoughts and tried, now I am desperately trying to find another way. Going to send my regards to Apple about this.
You can not launch an application without user interaction. The user has to click on the app icon, on push notifications, on a custom link. May be there are other ways I am not aware of, but even if they exist, they require user interaction to intentionally launch the app.
Edit
It turns out, as Tim mentioned, there might be an exception for VOIP apps.
I have been developing VoIP apps and I can confirm that VoIP app will autostart when iPhone reboots as long as user doesn't kill it before reboot. When iOS autostart voip app only application:didFinishLaunchingWithOptions: will be run, i.e. applicationDidBecomeActive: won't be run.
I used to doubt whether iOS will automatically restart the voip app when it crashes. After investigating I find iOS does automatically restart the voip app but if it keeps crashing iOS will then try servals time before it finally gives up.
If you check iPhone console output from xcode, you can see logs like these after the first crash
..
Service exited due to signal: Abort trap: xxx
Unable to get short BSD proc info for xxxx: No such process
Application 'UIKitApplication:xxxxx]' crashed.
...
Significant location change or region monitoring also causes an app to launch on boot as long as its turned on and left on. No UIBackgroundModes key is necessary for this.

how to see iphone logging (NSLog) after app restart?

How could I view iphone logging (eg NSLog) after app restart?
I'm interested in the answer both for using the (a) simulator and (b) an IOS device.
Background - In this case I have some issues no doubt in my code with how the application is supposed to launch, get previous state, and goto the controller/view it was at prior to it being terminated. Hence I want to see the logging as it starts up.
For seeing device logs, you can use Organizer tool available in XCode(your device should be connected with system).
For simulator you will have to re-run application from XCode.
Thanks,

iphone Location Services code that works on OS 4.1 in appstore

There's a bug in OS 4.1 that has broken location services for some iPhone apps ( https://devforums.apple.com/message/306250 ). Basically location services fails to turn on, and doesn't even ask the user for permission to get their location. The worst thing about the bug is that it doesn't occur when you're installing the app to a device from XCode, it occurs you when you're downloading from the App Store! This makes it almost impossible to test for a fix.
Not everyone's app has been affected, so I'm trying to find out what causes it.
Does anyone have any location services code that's NOT affected by this problem? In other words, who has code for an app that has location services working fine on OS 4.1 devices, when installed from the AppStore?
Thanks!
Tristan
I have found a workaround-Solution: Reset the location warning. (Settings > General > Reset > Reset Location Warnings)
I have seen this occur with apps I have developed when the device has installed a testing version provisioned under a distribution profile and then installs the final version submitted to the app store. The symptom is that Location Services never seems to initialize or ask for permissions and you wind up never being called back with a location or an error to handle.
We have verified that rebooting the device does NOT fix it, but that resetting the location warnings does. In our testing, this only affects devices that ran developer provisioned builds and not 'pristine' devices that only install the App Store build.
I worked through this with the apple help people. Resetting location warning didn't work. Resetting the network didn't work.
Basically, I reset the phone in itunes and set it up as a new phone. The location now works.