How Do I Use the Beacon Storage API?

Follow

In simple words, Beacon Local Storage allows for storing any data on the beacon. You can use the available 128 kB of storage to keep text, pictures, or even audio data. Each data piece is available under the predefined string based key. Think of it as common dictionary like API familiar to any developer. Data can be written using the Beacon Local Storage API during an authorized connection to the beacon. Reading of the data does not require authorization, and can be performed fully offline by simply using a Bluetooth LE connection.

Beacon Local Storage can greatly boost existing projects. Make your shopping experience more relevant, based on customers visits. Migrate your hardcoded data from the mobile application to the spot it is truly related to. Deliver dynamic data offline in spaces where internet connection is poor. Improve the security of your deployment that requires physical presence.

A new world of experiences is possible as well! Make an offline loyalty app that collects secure codes from the beacons. Leave local messages dynamically generated by the people physically visiting a place. Create offline games for which delivered content can evolve over time. Your imagination is the limit!

How it works

To access Beacon Data Storage, we introduced a new API called Beacon Data Storage API to our Location Beacons. It is available through the Estimote SDK. Each device you discover is capable of an offline/online connection, delivering API to access read and write functionality. To perform the write operation, just use the code snippet below:

// After ranging ESTDeviceLocationBeacon use -(void)connect
[self.device connect]; // When connection will be established use ESTStorageManager object
// that is property of ESTDeviceLocationBeacon class.
- (void)estDeviceConnectionDidSucceed:(ESTDeviceConnectable *)device { NSDictionary *storageContent = @{ @"message" : @"Hello World!"};
[self.device.storage saveStorageDictionary:dictionary
withCompletion:^(NSError * _Nullable error) { if (!error)
{
NSLog(@"Saved dictionary to Estimote Storage with success!");
}
}];
}

Reading data from the beacons is similarly simple:

// Reading from Estimote Storage after ESTDeviceLocationBeacon was ranged
[self.device connectForStorageRead];

// After successful connection callback will be called
- (void)estDeviceConnectionDidSucceed:(ESTDeviceConnectable *)device {

[self.device.storage readStorageDictionaryWithCompletion:^(NSDictionary * _Nullable value,
NSError * _Nullable error) {

NSLog(@"Current Estimote Storage's content: %@", value.description);
}];
}

To ensure security, Estimote Cloud based authorization is required for the write operation, thus you need to have an internet connection. Reading data from the device is publicly available and completely offline. If data stored on the device needs to be secured, any encryption mechanism can be used before saving data to the beacon.

Was this article helpful?
0 out of 0 found this helpful

0 Comment(s)

Estimote is
hiring!