开发者

Enable Location Services programmatically inside application on iPod Touch

I have an iOS application that uses GPS for Location Services. A user would like to use the app on an iPod Touch with an external GPS, but the problem is that the user can't enable Location Services in Settings->General Settings->Location Services for this app.

When the app is run on an iPhone, in Settings->General Settings->Location Services, the app shows up with a toggle switch to enable/disable Location Services for this app. But when the app is run on an iPod Touch, the app doesn't show up in Settings->General Settings->Location Servi开发者_开发技巧ces.

Does anyone know what I need to do programmatically to cause Location Services for this app to show up with a toggle switch in Settings->General Settings->Location Services when run on an iPod Touch?


I think that the ability comes when CLLocationManager is implemented for the first time. I'm not sure if that is what's used with an external GPS receiver but if you're getting the Lat/Long from the GPS, you can send those coordinates to the location manager.


I figured out what the problem was. I had the following code that only allowed Location Services for iPhone and not for iPod. Oops!

if([model hasPrefix:@"iPhone"]){

    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    self.locationManager.distanceFilter = 10.0f;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [self.locationManager startUpdatingLocation];
    self.locations = [NSMutableArray arrayWithCapacity:32];

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜