iosobjective-ciphonenotificationsestimote

Estimate Beacons IOS - Search Beacons with only UUID Value


I am into Estimote Beacon app development and was able to send notifications using the sample app where the UUID, Major and Minor values are explicitly hardcoded in the code. I want the below requirement to be implemented using Objective C.

  1. App will search for Beacons based on UUID, if I have 10 beacons, the Beacons are differentiated based on major and minor values and UUID is kept constant.
  2. Once notification is send, the user clicks the app and the app should be able to determine the major and minor values of the Beacon that is in range.
  3. Also, is it possible to make a custom service call along with sending the notification?

I was able to send notifications using the below code with hardcoded UUID, Minor and Major values.

The code which is working for me is the below one:

self.beaconNotificationsManager = [BeaconNotificationsManager new];
[self.beaconNotificationsManager enableNotificationsForBeaconID: [[BeaconID alloc] initWithUUIDString:@"MY UUID" major: 10708 minor:33584] enterMessage:@"Enter Message." exitMessage:@"Exit Message"];

Thanks, SIB Mobile Developer


Solution

  • You can use Ranging Beacons to achieve sending 'Entry' and 'Exit' notification and background service call.

    NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"YOURUUID"];
    
    self.beaconManager = [[ESTBeaconManager alloc] init];
    self.beaconManager.delegate = self;
    self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"RegionIdenifier"];
    
    self.beaconRegion.notifyOnEntry = YES;
    self.beaconRegion.notifyOnExit = YES;
    self.beaconRegion.notifyEntryStateOnDisplay = YES;
    

    Then to send notification inside Delegate method:

    -(void)beaconManager:(ESTBeaconManager *)manager didEnterRegion:(CLBeaconRegion *)region
    {
        UILocalNotification *notification = [[UILocalNotification alloc] init];
        notification.alertBody = @"Enter region notification";
        notification.soundName = UILocalNotificationDefaultSoundName;
    
        [[UIApplication sharedApplication] presentLocalNotificationNow:notification];
    }
    
    -(void)beaconManager:(ESTBeaconManager *)manager didExitRegion:(CLBeaconRegion *)region
    {
        UILocalNotification *notification = [[UILocalNotification alloc] init];
        notification.alertBody = @"Exit region notification";
        notification.soundName = UILocalNotificationDefaultSoundName;
    
        [[UIApplication sharedApplication] presentLocalNotificationNow:notification];
    }