I am storing Location settings in the settings bundle. So when I flip a switch to NO, my app stops the background location service.
I am using an observer to detect settings change, and updating a flag in my app. The problem is, if I flip the switch to OFF, my app does not stop the location service till I open the app. This is understandable, since my observer resides in the source code. Is there a way to listen for the settings while the app is in the background? I am an iOS development newbie, so I do not understand the concept of background and foreground so much.
Its not possible is what I found.
Related
When the application is sent to the background, i need the application to shutdown completely. Presently, when my app goes to the background, and when i call it back it shows the view i was working before it went to the background.
I am doing this to release memory.
How can i do this programatically ?
Add a key UIApplicationExitsOnSuspend to YES on info.plist
More info here
https://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html
Go to your configuration (e.g plist file) and add the following tag :
UIApplicationExitsOnSuspend and set it to true
Do not prevent your app from multitasking just because you have memory issues. What you should do is optimize your code and correct these issues.
Look at this guide and the methods that it mentions, they will allow you to know if your application is going to the background for example so that you can release some memory.
My app runs significant location change updates in the background. However the GPS display icon never turns off..even when app is in the background. Is there a way to use location manager with Significant location change in the background and have the GPS icon NOT display continuously? My users don't understand that it is only periodically obtaining location coordinates and instead think its constantly running in background and thus deleting app thinking its too power intensive. Please help.
I believe that any use of CoreLocation will prompt the location arrow. That includes any of the geofencing CLRegion use, -startMonitoringForSignificantLocationChanges, and -startMonitoringForLocation. I think that is Apple's safeguard that something is using your GPS, even in limited use.
That arrow will be visible till you unregister your application from significant change. But I faced problem, what I can't fine point where I can do this. In my case will be best to unregister on application kill, but with multitasking there is no such ability to handle this moment to unregister.
When we play our app on the device(ios 4.0 and above) and leave mid workflow, and return later, we return mid workflow. I want that it should not replay from the same left point rather the main screen should load(i.e, the same thing that happens on calling viewDidLoad of our rootViewController).
Please give suggestions if it is possible and if not then please post the reason behind that.
Here's an alternative approach, disable background mode and restart your app every time it enters the foreground: add UIApplicationExitsOnSuspend key to your app's info.plist and set its value to YES.
UIApplicationExitsOnSuspend
UIApplicationExitsOnSuspend (Boolean -
iOS) specifies that the application
should be terminated rather than moved
to the background when it is quit.
Applications linked against iOS SDK
4.0 or later can include this key and set its value to YES to prevent being
automatically opted-in to background
execution and application suspension.
When the value of this key is YES, the
application is terminated and purged
from memory instead of moved to the
background. If this key is not
present, or is set to NO, the
application moves to the background as
usual.
This key is supported in iOS 4.0 and
later.
So actually you want to quit the app on Home button press and restart?i.e turn multitasking off?
Search for info on UIApplicationExitsOnSuspend
Yes you call your rootviewcontroller from applicationDidUnhide to do so. You'll have to twist your logic a little (have to reset your variables on this method call).
Edit: You should instead use applicationDidBecomeActive. Reference is on same link.
I am developing an iPhone app which uses CoreLocation.
I'm having trouble finding out if the CoreLocation location continues to get updated when the app enters the background. I would like to have it stop updating, but I am not sure if I need to explicitly tell it to stop or not.
Could anyone shed some light on this?
You need to explicitly set whether your application will run in background mode. As documentation says Background Execution
Also you notice an icon in status bar will disappear when core location stops updating location data when your app. go to background mode
Kindly check the following url .. hope it is useful to you
http://numiko.com/labs/?p=238
As with most things, programming related; if you want an action to occur, you almost always need to tell it to do that thing, or an ancillary thing which side effects that.
If you want it to stop updating, tell it to do so. (And yes, there are two different modes that will collect location info in the background. One is only on the iPhone 4 though.)
My App needs a Internet Connection which is checkt in the ViewDidLoad if there is no Internet connection I want to terminate the app when the Home Button is clickt so that the app start in its initial state next time but only in this case.
If there is a Internet connection from the start the homeButton should bring the app just to the background.
Apple does strongly discourages quitting from application programmatically.
I think you can handle your case without quitting application - when application goes to background(in applicationDidEnterBackground method of application delegate) save some flag indicating that you want to reinit it on resume, then when application comes back to foreground (applicationWillEnterForeground method in delegate) apply your initialization logic in case flag is set.
Programatically terminate an App is a behaviour that will be rejected to be published in the AppStore, as it seems that the application crashed.
If you don't mind that your application will never see the light at the AppStore, you can simply use exit(0).
When your app does not find an internet connection, switch to a view that exactly imitates your Default start-up image, then force that view to stay visible the usual amount of start-up time after any call to making your app active. You can also kill and recreate fresh all your other MVC objects during this time.
That way, no one will know that your app wasn't freshly started when brought back from the background.