开发者

Detect iPhone device capabilities for Core Location

开发者 https://www.devze.com 2023-01-20 02:30 出处:网络
I have a core location app that I\'m writing leveraging the startMonitoringSignificantLocationChanges method to generate updates when appropriate but this does not work on older devices such as iPhone

I have a core location app that I'm writing leveraging the startMonitoringSignificantLocationChanges method to generate updates when appropriate but this does not work on older devices such as iPhone 3g.

I would like for the core location functionality to still work while the device is open, so I thought I could use a selector test to see if the device supports the method, and if it doesnt just use the standard core location updating method. Although this selector doesnt work on my iphone 3g, it still uses startMonitoringSignificantLocationChanges even though it doesnt work on the p开发者_如何学Chone.

Any ideas? I would rather not use the device identifier tests because then it will have to be updated for every future release of the phone.

   @interface RootViewController : UITableViewController  <CLLocationManagerDelegate>  {
    CLLocationManager *locationManager;     
}
@property (nonatomic, retain) CLLocationManager *locationManager;

@implementation RootViewController
@synthesize locationManager;
    if([locationManager respondsToSelector:@selector(startMonitoringSignificantLocationChanges)]) {
            [locationManager startMonitoringSignificantLocationChanges];
            NSLog(@"Using bg updates");
        }
        else {
            [locationManager startUpdatingLocation];
            NSLog(@"Using reg updates");
        }


if ([CLLocationManager significantLocationChangeMonitoringAvailable]) {
…
}
0

精彩评论

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