I'm trying to grab the iBeacon advertising code from AirLocate sample code into an empty app. It looks like:
NSDictionary *peripheralData = nil;
region = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:beaconUuid] major:beaconMajor minor:beaconMinor identifier:beaconIdentifier];
peripheralData = [region peripheralDataWithMeasuredPower:nil];//[NSNumber numberWithInt:power]
// The region's peripheral data contains the CoreBluetooth-specific data we need to advertise.
if(peripheralData)
{
[peripheralManager startAdvertising:peripheralData];
return YES;
}
The empty app is able to emit iBeacon signal which can be successfully be monitored by another app on another device. But the problem is on another app, locationManager:didEnterRegion: delegate method is followed by locationManager:didExitRegion: very quickly.
Peripheral device: iPad mini 2 retina Central device: iPhone 5S
Running the AirLocate app to separately configure one device as iBeacon emitter and another device as monitor can also reproduce the issue mentioned above.
Some other findings:
- If you just leave the receiver app as is, it will report didEnterRegion automatically in a few minutes, followed by didExitRegion quickly, still the same problem.
- If you move the emitter app to background mode by pressing home button and enter the same app again, the receiver will trigger another round of those two monitoring methods, still the same problem.
My guess is the frequency of iBeacon advertising is so small (say, once a few seconds) that the receiver may think the region is exited before receiving the package again. It may also be a bug in iOS.
Does anyone know about it?