iOS - How to get rid of "app is using your location" notification - ios

I'm using Google Map SDK 1.8.1 on ios 8,
I set Allow Location Access While Using The App:
And then everytime I using GMSMapView and Home, this one shows up.
(When there is an UIViewController that contains GMSMapView in navigation stack)
How can I dismiss it programmatically ?
Thanks you.
edit: sorry, I didn't make my question clear enough.
What I mean is how can I stop GMSMapView from using Location Service when users press Home button, I think that will do the trick.
I tried Google Map's app, the notification view does disappear when you Home, so I think it is possible.

You can't prevent the banner from displaying while you're using the user's location, it's information for the user provided by the system, for them to make informed decisions about which apps they share their location with and when.
Even if you found a way to do this, I'd be extremely surprised if it would get through app review. There's no specific rule about it, as it's not an option in the API anyway, but the gist of the guidelines is that the user should know what you're doing with their location, and when you're tracking it:
4. Location
4.1 : Apps that do not notify and obtain user consent before collecting, transmitting, or using location data will be rejected
Edit - responding to home button press
In order to stop using location when the user presses the home button, you need to subscribe to notifications about entering the background. When you initialise your class which is using location, register for the following:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(appWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
Then, in the method which is called for that notification, stop using location:
-(void)appWillResignActive:(NSNotification*)note
{
//stop using location here. I'm not familar with GMSMapView, but assuming you have a reference to the map view, the documentation suggests this:
self.mapView.myLocationEnabled = NO;
}
You may also want to register for the UIApplicationWillEnterForegroundNotification so that you can pick location services back up again when the user opens your app again from the app switcher.

No way to hide it. Even if I stop Location updates.
One thing is for sure:
You must use NSLocationAlwaysUsageDescription in info.plist
and
request requestAlwaysAuthorization from LocationManager
in order to
hide the blue bar forever (and still have the background capability because of Location updates).
PS: I've seen someone speaking about having the blue line disappear after a while but that did not happen to me. Can anyone confirm of auto hiding blue bar?

Related

How to hide Location icon in an iOS app on screens that do not require it?

I am developing an iOS app with Xamarin.iOS.
I have granted permissions to use Location Services, and the Location icon is visible in the Status Bar as long as the app is running.
However, my app needs to get the current location on one screen only - the rest of the time location is not needed.
Is it possible to turn off (hide) the Locations icon when app is not really using it?
Answers I found are for old iOS versions or work on jailbroken phones. It is my understanding that Apple is preventing this now. I would appreciate a confirmation if this is at all possible or not. Or if it is possible - some Xamarin / Objective-C /Swift examples would be great.
U mean the airplane ICON in status bar?
This ICON will show when APP using location service, try to stop or remove your location request or mapView, your map SDK have their own interface, like:
locationManager = [[CLLocationManager alloc]init];
[locationManager stopUpdatingLocation];
and be sure other APP not using location service.
but it NOT sure the service will stop immediately, location manager just a monitor to system.
You can use requestAlwaysAuthorization instead of requestWhenInUseAuthorization on CLLocationManager.
NOTE : Provide the related NSLocationAlwaysUsageDescription in the
info.plist file, and then Blue Banner will not display.

Blue banner '%MyApp% is Using Your Location' for app that uses location services only when active

In my app I'm updating user location every time when app becomes active. I stop CLLocationManager once updated location is received or in applicationWillResignActive:.
In Info.plist there is a NSLocationWhenInUseUsageDescription with appropriate description.
If app is activated and then immediately moved to background, blue banner saying that '%MyApp% is Using Your Location' appears for less then a second. This banner gets hidden as soon applicationWillResignActive: is called.
I've noticed the same problem in Google Maps, but not in Apple Maps.
Is there a way to get rid of this banner completely? Is there anything else I should do to make iOS happy? I do not want it to freak out my users and prevent them from using cool features that require location.
You have probably set location as Background mode in your info.plist. If you remove that, then the blue bar won't appear anymore.
Or, you can use requestAlwaysAuthorization instead of requestWhenInUseAuthorization on CLLocationManager (and provide the related NSLocationAlwaysUsageDescription in the info.plist file), and then it will not appear either.
In my case, my app is using location in the background in some cases, and I would like the blue bar to appear when that is the case. But I do not want it to appear when exiting the app without location in background. As far as I know that is not possible to achieve (I've asked about it here).
EDIT: Note that starting with iOS-9, you can make sure that the blue bar only appears when the user actually wants the app to use the location in the background. See this answer.
If you want to get access to the user's location with CLLocationManager, the app will need to show that banner and the user will need to press "Allow". If they don't do that, your location manager won't be able to detect the user's location.
Apple's Maps is a special case because it's a first party app.

MapView hiding "Allow location services" prompt

The first screen of my app is a MapView so when the user opens it up for the first time it prompts for Location Services. The issue is that immediately after the prompt comes up asking for location access it gets hidden (fades into the background) like some subview came over top of it.
Does anyone have a fix for this?
It sounds like you are either proceeding with another prompt for location services before the confirmation is given, or else you are on iOS 8 and prompting for location services (which is now asynchronous) and then going ahead and using them before this can complete.

iOS : Detect user location when App is back from Background

I have a MKMapView & I use it to display user's current location. It works normal when I first load it in the App. But when I press Home button to put the App to background & call it back from background, the map prompts it is unable to find the user's location.
I was thinking is the MKMapView takes time to search for user's location, and when I call it back from background, it does not have enough time to load the location service ?
iOS5 SDK, xCode 4.3 is used.
If I understand your question correctly, your problem is that when your app resumes (becomes active), mapView.userLocation returns nil. Although I haven't tested this, I suspect it is because the mapView will need some time to relocate the user. You can get around this by adding your logic to the appropriate delegate method instead, which is - (void) mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation, if memory serves me right (you might want to verify that, though).
EDIT: Make sure you test location-related code on a device, since its behaviour might differ from the simulator.

CLLocationManager don't stop

Dear fellow developers,
I am trying hard to find a solution for my problem regarfing CLLocationManager.
I use a CLLocationManager instance in my Application. If the user selects the Home button on the device or terminates the application I want the location services to stop.
Therefor I call [self.locationManager stopUpdatingLocation]; - But this somehow doesn't work. The application enters the background and the small location arrow in the upper right corner of the status bar don't disappear. Even if I add [self.locationManager release] or self.locationManager.delegate = nil; - the location tracking don't stop :-/
It only disappears if I go to my device settings and switch off location services for the app. Whenever I switch back to location service enabled I immediately get a purple colored arrow next to the switch toggle and the icon reappears in the status bar.
My question is how can I turn off location services when the app enters the background or is terminated?
Thanks a lot in advance and have a nice day :-)
Your location is disabled. The location service icon "meaning" has changed on iOS 5. Take a look at this question: https://apple.stackexchange.com/questions/27463/why-is-the-location-services-icon-always-present
I Quote the answer:
It's a new feature in ios 5 called "region Monitoring"
The reason it's active even if the app is closed is that this feature
runs in iOS 5 core and notifies all apps that are registered when they
have entered or left a specific geo-fence.
Reminders does that when you use a location based reminder.
Although the location icon appears at all time. This actually has very
minimal impact on the battery due to apple really optimizing this
feature by using cell and wifi mostly.
Your app is working ok. The system behaviour is the one who changed.
You do it the right way. When entering background, it's ok if some delegate methods are called for some seconds. That should stop.
Where do you stop the location updates ? Are you sure it is triggered ? If yes, are your delegate method called even if the visual indicators tell something else ?
Are you sure you don't trigger a method that reactivate the location update after you have stopped it (because for example you can receive some updates even after stopped).
For instance if you started monitoring a significant location change, then you should unsubscribe from it with the corresponding pair method. If you are using region enter, then until you unsubscribe, the system will notify your delegates.

Resources