I have the particle ibeacon working entering and exiting a region. I leave my house it says be safe, I come home and it greets me. I have the table set up so when I am unknown, far, near and immediate the appropriate responses tell me on my cell. I am using this switch
switch (proximity) {
case CLProximityUnknown:
return @"unknown";
NSLog(@"This is the cell talking");
break;
case CLProximityImmediate:
return @"Immediate";
NSLog(@"This is immediate cell talking");
break;
case CLProximityNear:
return @"Near";
break;
case CLProximityFar:
return @"Far";
default:
break;
}
This works perfect. So in my main view controller I added this
-(void)actionForProximity:(CLProximity)proximity
{
UILocalNotification *notification = [[UILocalNotification alloc]init];
switch (proximity) {
case CLProximityImmediate:
notification.alertBody = @"You are in immediate danger!";
notification.soundName = @"Default";
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
NSLog(@"You are in immediate proximity to the beacon");
break;
case CLProximityNear:
notification.alertBody = @"You are very near";
notification.soundName = @"Default";
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
NSLog(@"You are near the beacon");
break;
case CLProximityFar:
notification.alertBody = @"Where are you going, you may get lost";
notification.soundName = @"Default";
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
NSLog(@"You are far from the beacon");
default:
break;
}
}
However it doesnt seem to cause a trigger at all. I used a break point and it doesnt seem to reach the method at all. I really want to use the proximity to trigger pop ups or in app controller etc... Any help would be so appreciated. Thank you for taking the time to read.
Your switch (proximity ) should be in your delegate method.
-(void)beaconManager:(ESTBeaconManager *)manager
didRangeBeacons:(NSArray *)beacons
inRegion:(ESTBeaconRegion *)region
DidRangeBeacons need an array of beacons.
The method
[self.beaconManager startRangingBeaconsInRegion:region]
returns you the array you need and should be in the ViewDidAppear
.
The delegate method is triggered every 20ms i think.
Hope this can help you.
( I m using Estimote SDK )