I am trying to implement iBeacon in a development situation where I don't have actual beacons for testing. I am using 'Beacon Bits', which is an emulator running on an iPad. I have tried other beacon emulators to eliminate the possibility that the emulator could be the problem. So, I am using an emulator running on an iPad and my app is running on an iPhone. I am not using the XCode simulator, both are actual devices.
I have added the necessary location manager authorizations that appear to be necessary in iOS8. I have also ensured that these are in my plist.
I have double checked that bluetooth is enabled on both the emulator and the device running the app that should detect the beacon emulator.
When I run the app, there is no response and none of the location manager delegate methods are fired. Here is the code for my view controller:
-(void)viewDidLoad {
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]){
[self.locationManager requestAlwaysAuthorization];
}
if([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]){
[self.locationManager requestWhenInUseAuthorization];
}
uuid = [[NSUUID alloc] initWithUUIDString:UUID_STRING];
self.region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:BEACON_NAME];
[self.locationManager startMonitoringForRegion:self.region];
[_responseLabel setText:@"Waiting..."];
}
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
[self.locationManager startRangingBeaconsInRegion:self.region];
NSString* foundMessage = [NSString stringWithFormat:@"Region Entered for: %@", BEACON_NAME];
[_responseLabel setText:foundMessage];
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
[self.locationManager stopRangingBeaconsInRegion:self.region];
}
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
[_responseLabel setText:@"BEACON FOUND"];
CLBeacon* foundBeacon = [beacons firstObject];
NSString* foundMessage = [NSString stringWithFormat:@"Beacon Found: %@", BEACON_NAME];
[_responseLabel setText:foundMessage];
}
Any suggestions on why this doesn't respond? Thanks!