0

I have an Estimote beacon that I am connecting to with my iOS app. I am successfully able to pass parameters like the major id and minor id, but I would also like to obtain the battery level and proximity and pass those along in the URL as well.

I have read through the documentation and it seems like there is a way to do this, but I haven't been able to figure out how to write it into this method. Any ideas would be extremely helpful!

-(void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons 
inRegion:(ESTBeaconRegion *)region {
    if([beacons count] > 0) {
        if(!self.selectedBeacon) {
            self.selectedBeacon = [beacons objectAtIndex:0];
        }
        else {
            for (ESTBeacon* cBeacon in beacons) {
                if([self.selectedBeacon.ibeacon.major unsignedShortValue] == 
                [cBeacon.ibeacon.major unsignedShortValue] &&
                   [self.selectedBeacon.ibeacon.minor unsignedShortValue] == 
                   [cBeacon.ibeacon.minor unsignedShortValue])
                {
                    self.selectedBeacon = cBeacon;
                }
            }
        }
        NSString *connectedToBeacon = [[NSUserDefaults standardUserDefaults] 
        stringForKey:@"connectedToBeacon"];

        if ([connectedToBeacon isEqualToString:@"FALSE"]) {
            NSString *userId = [[NSUserDefaults standardUserDefaults]
                                stringForKey:@"userId"];
            NSString *beaconURL = [NSString stringWithFormat:@"%@/directory/page.php?
            major=%i&minor=%i&user=%@", curr_host_variable,
            [self.selectedBeacon.ibeacon.major unsignedShortValue], 
            [self.selectedBeacon.ibeacon.minor unsignedShortValue], userId];

            NSData *BeaconURLResult = [NSData dataWithContentsOfURL:[NSURL 
            URLWithString:beaconURL]];   
        }  
    }
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Brandon
  • 1,701
  • 3
  • 16
  • 26

1 Answers1

0

This is Wojtek Borowicz, I'm a communityt evangelist at Estimote.

You should be able to find the information you're looking for right here: http://estimote.github.io/iOS-SDK/Classes/ESTBeacon.html#//api/name/readBeaconBatteryWithCompletion: Keep in mind however, that soon we might be changing the option to fetch battery level from our SDK, as we're going to introduce changes to how this parameter is calulated.

Cheers.

Wojtek Borowicz
  • 465
  • 2
  • 8