Estimote / react-native-proximity

React Native wrapper for Estimote Proximity SDK
Apache License 2.0
61 stars 38 forks source link

Background actions #50

Open hadare1 opened 4 years ago

hadare1 commented 4 years ago

Hi, I just received the starter kit and stetted up a play ground in react-native 0.61.5.

How exactly does the background mode works? I enabled the backround bluetooth in xCode and my I initialize the proximityObserver with this config:

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',
      },
    },
 };

I stetted up remote notification (which I know works) but when the phone is locked I do not receive these notifications. this is my proximityObserver startObserving method:

 zone1.onChangeAction = async contexts => {
  console.log('zone1 onChange', contexts);

  if (contexts.length > 0) {
    try {
      const data = {
        'restaurantName':'demo',
        'channel': 'channel1',
      };
      const res = await axios.post(`${this.url}/beaconTestNotification`, data);
    } catch (e) {
      modalCompatibleAlert(e);
    }
  } else {
    const data = {
      'restaurantName': 'Exit Demo rest',
      'channel': 'yDBu1uyduacwjC1iDaR6kDuiZfE3',
    };
    const res = await axios.post(`${this.url}/beaconTestNotification`, data);
  }
};

this is not called when the phone is locked. should I do anything else? am I missing something? I haven't notice any other configuration in the docs.

Thanks

hadare1 commented 4 years ago

Okay so I figured I did not have the "always" on the location permissions on. So I got it to work on Background mode but it does not work when app is closed.

is there any more configuration I need to do in order to make this work?

nandorojo commented 4 years ago

By background mode, do you mean when the app is not currently open but still running in the background?

nbastoWM commented 3 years ago

I'm also trying to detect beacons when the phone screen is off or when the app is minimized, but I can't see how can I ask for "always" location permission in iOS with this package.