Question

I'm making a Notification Center for jailbroken iPhones using the theos templates (so it runs on WeeApp). It's a weather widget, and I want it to be able to get the phone's current location so it can get weather from the closest station. I'm currently using the following code to start getting locations:

i_locationManager = [[CLLocationManager alloc] init];
i_locationManager.delegate = self;
i_locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
i_locationUpdated = NO;
[i_locationManager startUpdatingLocation];

and I have a didUpdateLocations method. All of that works fine. The problem is with the pop-up the phone uses to get permission to use the location. First of all, it says that SpringBoard wants to use the location. Is there any way to get it to say my widget's name instead?

More importantly, the saved permissions don't stick. They last as long as the phone is running, but every time I respring and open the Notification Center again, it re-asks for permission to use the location.

This isn't a fatal issue, of course, but it's irritating. Is there any way to get the phone to remember that the widget is allowed to use the current location?

Was it helpful?

Solution

This might help

[CLLocationManager setAuthorizationStatus:YES forBundleIdentifier:@"com.apple.springboard"];

This will authorize SpringBoard programmatically. First time you can display pop-up and save somewhere that user authorized you. Then you can do it yourself everytime you need location.

As for application name in pop-up. You can try hooking UIApplication, SBApplication, NSBundle methods that return application name. I don't think there is easier way to do it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top