I have installed the react-native-proximity and test on the example as provided recently. The app keep on crashing. These are my codes:
"use strict";
import * as RNEP from "@estimote/react-native-proximity";
const startProximityObserver = () => {
const ESTIMOTE_APP_ID = "my-attendance-4f8";
const ESTIMOTE_APP_TOKEN = "9f39c19fb0973f109b17df865462b5bc";
const zone1 = new RNEP.ProximityZone(1, "Purple");
zone1.onEnterAction = context => {
console.log("zone1 onEnter", context);
};
zone1.onExitAction = context => {
console.log("zone1 onExit", context);
};
zone1.onChangeAction = contexts => {
console.log("zone1 onChange", contexts);
};
const zone2 = new RNEP.ProximityZone(1, "Green");
zone2.onEnterAction = context => {
console.log("zone2 onEnter", context);
};
zone2.onExitAction = context => {
console.log("zone2 onExit", context);
};
zone2.onChangeAction = contexts => {
console.log("zone2 onChange", contexts);
};
RNEP.locationPermission.request().then(
permission => {
console.log(`location permission: ${permission}`);
if (permission !== RNEP.locationPermission.DENIED) {
const credentials = new RNEP.CloudCredentials(
ESTIMOTE_APP_ID,
ESTIMOTE_APP_TOKEN
);
const config = {
notification: {
title: "Exploration mode is on",
text: "We'll notify you when you're next to something interesting.",
channel: {
id: "exploration-mode",
name: "Exploration Mode"
}
}
};
RNEP.proximityObserver.initialize(credentials, config);
RNEP.proximityObserver.startObservingZones([zone1, zone2]);
}
},
error => {
console.error("Error when trying to obtain location permission", error);
}
);
};
const stopProximityObserver = () => { RNEP.proximityObserver.stopObservingZones(); };
export {startProximityObserver, stopProximityObserver};
There is no error shown. The app just crash as soon as I allow the bluetooth access by pressing allow button. The problem is with this line
RNEP.proximityObserver.startObservingZones([zone1, zone2]);
When I removed this line of code, the app will stop crashing, however no log will be shown. Is it because of the tag name? Will the app crash if tag name was wrong? Or is there something wrong with this function? Kindly assist me to solve the issue. Thank you. Sorry for any inconveniences caused…