Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

objective c - What determines the presence of the iPhone Location Services icon in the status bar?

Here's my situation. I'm developing an iPhone application that uses Core Location to determine the device's location. There is an icon: the Location Services Icon, that appears in the device's status bar. I know enough to say that the purpose of the icon is to tell the user that Location Services are currently being used by something. To the perceptive user, this means decreased battery life. For that reason, I want to be sure that the icon is displayed only when Location Services are actually being employed by my app.

Enter confusion. We, as developers, do not get access to the status bar via the official SDK. This means that the OS will display that icon automatically based on the behavior of the app. Try as I might, I cannot find a clear definition of what exactly causes that icon to show up.

As it stands, the icon appears before my app delegate gets control, and stays visible as long as the app is installed, running or not. This is clearly the worst case possible, and it made me doubt my use of CLLocationManager. I would elaborate on my use, but as an extreme case I tried removing the CoreLocation framework (and the MapKit framework, which I suspect also uses CoreLocation), and all code relating to location. The app still caused the icon to appear and stay until I deleted the app. I then made a brand new app, and made no changes except to change the app identifier to match the identifier of my app. The icon still appeared. I changed the identifier to use the identifier of one of my apps that did not use location, and the icon did not appear. I did make sure to reset the device during this testing.

This issue is really killing me. I cannot imagine what the application ID has to do with the Location Services icon, but I see no other cause for its persistence. It seems like a Red Herring hiding the real issue, but I'm at a loss as to the real issue.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here's an update and a solution I've come to after some fiddling. Since my problem was clearly an issue with the OS making some connection between my app's ID and the Location Services icon, I tried resetting the device's location warnings, which I did not originally know I could do. For the curious, this can be accomplished through the Settings app, then General > Reset > Reset Location Warnings. After making this reset and upon reinstalling the app, it again requested to use Location Services. Now, the icon appears precisely on startUpdatingLocation and disappears precisely on stopUpdatingLocation, exactly as I originally intended.

I have no idea what initially caused this condition, and I have little doubt that the condition itself is an OS bug, as indicated by Matthew Frederick, but, at least in my case, the condition is curable.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...