10

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.

kjam
  • 809
  • 1
  • 7
  • 17
  • you means, user have not taped on "Allow" and "cancel" on popup and immediately moved to background..? – aBilal17 Oct 23 '14 at 13:18
  • You mean you want to use their location without telling them? To solve your problem, you could start acquiring the location after say ten seconds. – gnasher729 Oct 23 '14 at 15:52

2 Answers2

12

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.

Community
  • 1
  • 1
fishinear
  • 6,101
  • 3
  • 36
  • 84
  • Don't use an answer to ask a question. If you have a question, ask it as a question! – matt Nov 25 '14 at 17:06
  • 1
    The first part is the answer. The last part was merely to point out the limitation of the answer. I have rephrased now. – fishinear Nov 25 '14 at 17:12
  • 1
    Sure, I'm just saying that maybe someone can help with the problem _you're_ having, and they won't see you asking for that help here. I can't, I'm afraid, but it's a big world of smart programmers, so you never know! So I'm encouraging you to ask it as a question. – matt Nov 25 '14 at 17:14
  • @matt thanks, I have already asked it as a separate question as well. – fishinear Nov 25 '14 at 17:16
  • I added a link from your answer here to your separate question. I think that's useful (for one thing, it makes your question show up in the Linked category at the right), but I don't mean to interfere; if you don't like it, roll back my edit! – matt Nov 25 '14 at 17:39
-3

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.

Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156