开发者

iphone significant location event not related to cell change

开发者 https://www.devze.com 2023-03-13 09:02 出处:网络
i have been using the significant event locat开发者_如何学运维ion manager on ios, but it seems it does not based on cell change as claimed.

i have been using the significant event locat开发者_如何学运维ion manager on ios, but it seems it does not based on cell change as claimed.

i used a simple application utilising significant location event, but i could not get a repeatable, consistent or sensitive response from the ios sdk.

i plotted the route (blue line), the cell towers(place mark) and a 1000m2 grid(blue square) on the map below. map showing route

the route was 5000m in distance.

i drove it 3 times.

  • test1. received 2 sig events
  • test2. none
  • test3. received 1 sig events

before u complain that my test is too small, i have been monitoring other test routes for days and all show the inconsistent shape.

i was expecting the sig event to be based on cell tower switching. so i used a jailbreak app called 'signal' to identify what is the active cell. (NB.it is surprising which cell is active. Not what i would expect.)

From monitoring the 'signal' application, the cells switched around 6-7 times from what i noticed.

yet i did not received 6-7 sig events. So i cant see any correlation between cell switching and significant events.

so i have the following questions

  • Q1. what is the significant event trigger?
  • Q2. why are the result unreliable/inconsistent.
  • Q3. how can i get make my app receive consistent and sensitive significant event to 500m?

This is the code that is running in the test app

 -(void)initLocationManager {
     if (locationManager == nil) {
         self.locationManager = [[[CLLocationManager alloc] init] autorelease];
         locationManager.delegate = self;
         locationManager.desiredAccuracy = kCLLocationAccuracyBest;
         [locationManager startUpdatingLocation];
         [locationManager stopUpdatingLocation];
         [locationManager startMonitoringSignificantLocationChanges];

     }
 }
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self initLocationManager];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
  fromLocation:(CLLocation *)oldLocation {
     NSLog(@"%@", newLocation);
     [[NSNotificationCenter defaultCenter]
 postNotificationName:@"PositionUpdate" object:nil];
 }

-lp


Significant Location changes are determined by iOS and there is nothing you can do to change their granularity directly. Note that it's only in iOS 4 that only the cell tower locations are used. Future versions of the operating system will improve this.

But as a workaround you could switch on normal CoreLocation position updates when the app get's woken/started by a significant location change. And then once you have the perfect result, disable Location Monitoring again to allow the app to go back to hibernation.


I just did a 3 kilometer test walk in fairly-central San Francisco with my app, and got zero Significant Change location events as well. I have a toggle in my app to change to normal polling with kCLLocationAccuracyHundredMeters and got 40+ events over the same distance.

Echoing the sentiments of various other answers herein and elsewhere, I'm holding off on Significant Change until iOS 5. I think the best thing to do right now is roll-your-own business logic to poll the old Core Location way, and ratchet frequency down gradually over time (or something) to be battery friendly.

Seems like in iOS 4, Significant Change is better suited for being able to tell which end of your commute you're at than which block (or even zip code) you're on.


I'm not sure if you have already looked at this - but the WWDC 2010 session 115 (Using Core Location in iOS) might give you a better idea of the the significant location change API.

0

精彩评论

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