The Gimbal VisitManager callbacks are called in the background, but they seem a touch unreliable. (Might just be my testing.)
In my testing (setup Gimbal Series 10 to default settings) when I removed the battery I didn't get a "didDepart" callback, but when I put the battery back in I got both at the same time. Walking the beacon 20 meters away didn't trigger them again, maybe I didn't wait long enough, etc.
// Definitely can trigger from background
- (void)didArrive:(FYXVisit *)visit;
- (void)didDepart:(FYXVisit *)visit;
// Handy code to discover when the background method is called
- (void)didArrive:(FYXVisit *)visit {
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:1];
localNotification.alertBody = @"Gimbal Arrive Visit";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
You can also put them in iBeacon mode https://stackoverflow.com/a/22666967 and then use the standard callback. This works 100% of the time for me, calling the didEnterRegion shortly after I arrive near a beacon configured for iBeacon mode.
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
// Start monitoring the region (called on app start, etc.)
NSUUID *frontDoorID = [[NSUUID alloc] initWithUUIDString:@"FC3DAF5A-6223-4D71-9DCD-452DC95E6CDF"];
CLBeaconMajorValue major = 1000;
CLBeaconMinorValue minor = 2000;
CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:frontDoorID
major:major
minor:minor
identifier:@"entrance"];
[self.locationManager startMonitoringForRegion:beaconRegion];
// Called even in the background
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
NSLog(@"Arrived at Beacon");
// Fire a local notification to show an indication that the background event happened
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:1];
localNotification.alertBody = @"Beacon Found";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}