Search code examples
ios6backgroundplistcllocation

Does anyone know of a walkthrough or tutorial on how to set the plist for iOS 6?


I need to set the plist to allow CLLocation to update the current location in the background.


Solution

  • Here is how you setup a geofence:

    {
      self.manager = [[CLLocationManager alloc] init];
      self.manager.delegate = self;
    
      CLLocationCoordinate2D location;
    
      location.latitude  = <some lat>;
      location.longitude = <some long>;
    
      [self.manager startMonitoringForRegion:
       [[CLRegion alloc] initCircularRegionWithCenter: location
                                               radius: 1.0
                                           identifier: @"someplace"]];
    }
    

    Then implement the delegate methods to respond appropriately:

    - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
    { NSLog (@"didEnterRegion"); }
    
    - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
    { NSLog (@"didExitRegion"); }
    
    - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
    { NSLog (@"monitoringDidFailForRegion"); }
    
    - (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region
    { NSLog (@"didStartMonitoringForRegion"); }