Acoustic Mobile Push Beacon Plugin
Requirements
- Acoustic Mobile Push Plugin (react-native-acoustic-mobile-push)
- Acoustic Mobile Push Location Plugin (react-native-acoustic-mobile-push-location)
Description
This plugin adds beacon support to your application. Beacons are defined on the web based console and synced down to the device. When a beacon fence is triggered an event is sent to the server that can trigger a push message back to the device. The application is also notified with an EnteredBeacon
event when beacon fences are entered and an ExitedBeacon
event when beacon fences are exited.
Installation
npm install --save <sdk folder>/plugins/react-native-acoustic-mobile-push-beacon
Post Installation Steps
Link the plugin:
react-native link react-native-acoustic-mobile-push-beacon
Please set the UUID used by your beacons in the MceConfig.json file for both Android and iOS. Without this information the devices will not be able to locate the beacons.
Constants Exported
uuid
Description
This constant provides access to the beacon UUID value in the MceConfig.json file.
Example
import {RNAcousticMobilePushBeacon} from 'NativeModules';
console.log("iBeacon UUID: " + RNAcousticMobilePushBeacon.uuid);
Module API
beaconRegions()
Description
Lists major beacon regions via a promise. The promise includes a list of beacons with the values; major
an integer and an identifier string named id
.
Example
import {RNAcousticMobilePushBeacon} from 'NativeModules';
var latitude = 40.7128;
var longitude = -74.0060;
var radius = 1000; // Meters
RNAcousticMobilePushBeacon.beaconRegions().then((beacons) => {
beacons.forEach(function (beacon) {
console.log("Beacon with major " + beacon.major + " has identifier " + beacon.id);
});
}).catch((error) => {
console.error("An error occured: " + error);
});
Events Emitted
EnteredBeacon
Description
This event is emitted when a user enters a beacon fence.
Example
import {RNAcousticMobilePushBeacon} from 'NativeModules';
const emitter = new NativeEventEmitter(RNAcousticMobilePushBeacon);
emitter.addListener('EnteredBeacon', (beacon) => {
console.log('The user has entered a beacon with the identifier: ' + beacon.id);
});
ExitedBeacon
Description
This event is emitted when a user exits a beacon fence.
Example
import {RNAcousticMobilePushBeacon} from 'NativeModules';
const emitter = new NativeEventEmitter(RNAcousticMobilePushBeacon);
emitter.addListener('ExitedBeacon', (beacon) => {
console.log('The user has exited a beacon with the identifier: ' + beacon.id);
});