1
votes

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!

3
Does your macbook supports BLE(Bluetooth low energy)? - ridvankucuk
You can't test with the simulator. use some device. stackoverflow.com/questions/22109083/… - ErasmoOliveira
I am not using the XCode simulator for testing. Both my beacon emulator and my app are running on physical devices. - Pheepster
my advice: implement didChangeAuthorization and didFail methods of the location manager delegate. maybe you get more info - Daij-Djan

3 Answers

2
votes

Try Apple's sample app AirLocate. (Search for it in the Xcode docs.) I'd suggest installing it on both devices and seeing if that works. If so, you can then test AirLocate as transmitter against your receiving app and figure out if it's sending or receiving that doesn't work.

My company also has an app on the app store called BeaconTest that you can download and try:

http://www.tinyurl.com/beacontest

1
votes

You might want to implement the locationManager:monitoringDidFailForRegion:withError: delegate and see if it throws anything.

Monitoring beacon regions counts as geofencing on iOS, so there should be a hollow location services icon in the status bar when you start monitoring. It will also appear near the app's row on the Settings - Privacy - Location Services screen. If it's not there, monitoring is not starting correctly.

I'd also implement the didDetermineState delegate and check what it says. I've experienced an issue before where a region was stuck in the "unknown" state.

0
votes

I can't see your entire implementation, but anyway have you checked that the UUID associated with your region is the same broadcasted by your iPad's app?