Search Beacons with only UUID Value

Hi Friends,

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?

Thanks,
Abin

Hi @South_Indian_Bank,

  • if you put the major and minor values to null, you will scan for all the beacons that have the specified UUID. Note that you can’t scan for a null UUID,

  • if you use the ranging (or monitoring) technology, the listener you set up wil provide you with CLBeacon objects, so you will be able to read the near beacon’s major and minor.

Hi Ximun,

When I tried to giving null values along with BeaconNotificationsManager, no notification is generated at all. It worked only when I provided the exact minor and major value.

I’s not the original -and normal- behavior…

Not clear on your reply.

What I described is the normal behavior, I don’t know why it doesn’t works with you :confused:

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”];

You’re using the Notification example aren’t you?

If you put the major and minor to null, you get no error?

Yes Notification Example. If I am using null, getting error as below:

incompatible pointer to integer conversion sending’void*’ to parameter of type ‘CLBeaconMinorValue’
incompatible pointer to integer conversion sending’void*’ to parameter of type ‘CLBeaconMajorValue’

I got it: you can’t pass null parameters to the method, but have to use the other constructors.

What I did:

- (CLBeaconRegion*) createRegionFromDictionary: (NSDictionary*)regionDict
{
    // Default values for the region object.
    NSUUID* uuid = ESTIMOTE_PROXIMITY_UUID;
    CLBeaconMajorValue major = 0;
    CLBeaconMinorValue minor = 0;
    NSString* identifier = @"default_region";
    NSString* value = nil;
    bool isMajorDefined = false;
    bool isMinorDefined = false;

    // Get region values.
    for (id key in regionDict)      
    {
        value = regionDict[key];

        if ([key isEqualToString:@"uuid"])
        {
            uuid = [[NSUUID alloc] initWithUUIDString: value];
        }
        else if ([key isEqualToString:@"major"] && ([value class] != [NSNull class]))
        {
            major = [value integerValue];
            isMajorDefined = true;
        }
        else if ([key isEqualToString:@"minor"] && ([value class] != [NSNull class]))
        {
            minor = [value integerValue];
            isMinorDefined = true;
        }
        else if ([key isEqualToString:@"identifier"])
        {
            identifier = value;
        }
    }

    CLBeaconRegion* region = [CLBeaconRegion alloc];

    // Create a beacon region object.
    if (isMajorDefined)
    {
        if (isMinorDefined)
        {
            region = [region initWithProximityUUID: uuid
                                     major: major
                                     minor: minor
                                     identifier: identifier];
        }
        else
        {
            region = [region initWithProximityUUID: uuid
                                     major: major
                                     identifier: identifier];
        }
    }
    else
    {
        region = [region initWithProximityUUID: uuid
                                 identifier: identifier];
    }
      
    return region;
}

It’s not very beautiful but it works ><

Do you have the fully working code for the same ?

It’s part of the Estimote Cordova plug-in.
Go to plugin/src/ios/EstimoteBeacons.m and search the createRegionFromDictionary() method.

Can we make any service calls in background when notification is pushed? The scenario is I am entering a region, based on beacon minor and major value, a service call is made to server and server will identify the location of the customer.

I don’t know if you can do a server call from a background service…