App with React Native Proximity on Actual Android Device keep on crashing

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);

    permission => {
      console.log(`location permission: ${permission}`);

      if (permission !== RNEP.locationPermission.DENIED) {
        const credentials = new RNEP.CloudCredentials(

        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…

06-21 16:42:33.761  5272  5272 E AndroidRuntime: FATAL EXCEPTION: main
06-21 16:42:33.761  5272  5272 E AndroidRuntime: Process: com.estimote, PID: 5272
06-21 16:42:33.761  5272  5272 E AndroidRuntime: java.lang.RuntimeException: Unable to start service com.estimote.scanning_plugin.packet_provider.service.PacketProviderWrapperService@9cdf894 with Intent { cmp=com.estimote/.scanning_plugin.packet_provider.service.PacketProviderWrapperService (has extras) }: java.lang.SecurityException: Permission Denial: startForeground from pid=5272, uid=10245 requires android.permission.FOREGROUND_SERVICE

These are the log myb it can help

I have found similar issues on github with no replies.

Is this issue solved?

Have you tried adding that permission to the manifest?

1 Like

Omg. Thanks the app works fine after adding

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

in my AndroidManifest.xml.
Thanks a lot!

1 Like

No, thank you :wink: I never would’ve been able to track down this bug without that error message since I don’t have a device that runs Android 9 so I could never see the stack trace

1 Like

Thanks for tracking this down guys, I’ll see if we can automatically add this permission to our React Native plugin.