forked from williamtran29/react-native-ibeacon-simulator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.android.js
41 lines (37 loc) · 1.14 KB
/
index.android.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @providesModule BeaconBroadcast
* @flow
*/
'use strict';
import React from 'react';
import {
NativeModules,
} from 'react-native';
const NativeBeaconBroadcast = NativeModules.BeaconBroadcast;
const BeaconBroadcast = {
checkTransmissionSupported: function() {
return new Promise((resolve, reject) => {
NativeBeaconBroadcast.checkTransmissionSupported(function(result) {
const errors = {
1: 'NOT_SUPPORTED_MIN_SDK',
2: 'NOT_SUPPORTED_BLE',
3: 'DEPRECATED_NOT_SUPPORTED_MULTIPLE_ADVERTISEMENTS',
4: 'NOT_SUPPORTED_CANNOT_GET_ADVERTISER',
5: 'NOT_SUPPORTED_CANNOT_GET_ADVERTISER_MULTIPLE_ADVERTISEMENTS'
}
if (result === 0) {
resolve()
} else {
reject(errors[result])
}
});
});
},
startAdvertisingBeaconWithString: function (uuid, identifier, major, minor) {
NativeBeaconBroadcast.startSharedAdvertisingBeaconWithString(uuid, major, minor, identifier);
},
stopAdvertisingBeacon: function () {
NativeBeaconBroadcast.stopSharedAdvertisingBeacon();
},
};
export default BeaconBroadcast;