I have developed on application which is also developed in android.
I have implemented the beacon region monitoring in iOS as follows.
#pragma mark - Start/Stop Monitoring
- (void)startMonitoring {
[self clearRegionWatch]; // This function removes the already registered monitored regions
NSArray *arrayOfSavedBeacons = [self getSavedBeacons];
if([arrayOfSavedBeacons count]){
for(Beacons *beaconModel in arrayOfSavedBeacons) {
beaconModel.region.notifyOnEntry = YES;
beaconModel.region.notifyOnExit = YES;
beaconModel.region.notifyEntryStateOnDisplay = NO;
NSLog(@"Monitoring start request: %@", [beaconModel dictionaryRepresentation]);
[locationManager startMonitoringForRegion:beaconModel.region];
[locationManager requestStateForRegion:beaconModel.region];
}
}
else{
UIAlertView* curr1=[[UIAlertView alloc] initWithTitle:@"No Beacons" message:@"No Beacon List Found From Server" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[curr1 show];
}
}
Above is the code that starts the monitoring.
Following is the code that i have written for Initialization of Location Manager Instance.
locationManager = [[CLLocationManager alloc] init];
if([locationManager respondsToSelector:@selector(startMonitoringVisits)]) {
//iOS 8.0 onwards
[locationManager startMonitoringVisits];
}
if([locationManager respondsToSelector:@selector(allowsBackgroundLocationUpdates)]) {
//iOS 9.0 onwards
locationManager.allowsBackgroundLocationUpdates = YES;
}
if([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
//iOS 8.0 onwards
[locationManager requestAlwaysAuthorization];
}
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager setDelegate:self];
[locationManager startUpdatingLocation];
Above code will initialise the location manager when app will start.
I want to get notified for the region entry and exit event.
My issue is my android app can detect the beacon entry from very long distance while iOS app can not detect the region enter or exit from far.
I don't know why this difference is coming?
What i have observed is beacon region monitoring sometime delayed the entry exit notifications by 2 to 3 minutes.
if android can detect the beacon region at particular range then why iOS app can not detect this?(it is significant difference in range form where both app can start to detect the app).
Any advice or suggestion would be helpful.
Thanks.
With iOS CoreLocation, the didEnterRegion
monitoring callback is made upon first detection of a beacon matching the region regardless of the signal strength of the beacon advertisement. The callback should fire when the bluetooth chip first sees an advertisement at all, and this should be at a similar range for both iOS and Android devices. While the maximum bluetooth detection range certainly varies between devices, and can be affected by adding a case, putting your phone in your pocket, or by obstructions, in typical use it does not vary a great deal.
A more likely explanation why you are seeing delays in detections is timing, not signal strength. In the background, iOS will defer to a bluetooth chip hardware detection slot to quickly match your beacon region. This is a limited resource, so if these are exhausted, iOS will fall back to periodic software scans to detect, which can take up to 15 minutes. You can confirm this hypothesis by placing your iOS device at the same location where Android first detects, and simply waiting to see if it eventually tests at that distance.
A few tips to make your detections faster:
Uninstall all apps that may monitor beacons on your iOS device, as they may be using up the limited hardware acceleration slots. (Approx. 30 across all apps on the device.)
Don't stop monitoring and restart unless you absolutely have to. This will put your app last in line to get a hardware acceleration detection slot.
Start ranging for beacons when you start monitoring. This won't affect background detection times, but will significantly speed up foreground detection times.