Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Does not receving any feedback with actions #35

Closed
evertonaleixo opened this issue Mar 19, 2019 · 5 comments
Closed

Does not receving any feedback with actions #35

evertonaleixo opened this issue Mar 19, 2019 · 5 comments

Comments

@evertonaleixo
Copy link

evertonaleixo commented Mar 19, 2019

I was tryng to execute the below code, but it is not working. I was using a Sunsung S7 with Android.

export default class App extends Component {

  constructor(props) {
    super(props);
    

    // will trigger when the user is within ~ 5 m of any beacon with tag "lobby"
    // you can add tags to your beacons on https://cloud.estimote.com, in Beacon Settings
    const zone1 = new RNEP.ProximityZone(2, "mil");
    zone1.onEnterAction = context => {
      console.log("zone1 onEnter", context);
      this.setState({tag: "Enter MIL"});
    };
    zone1.onExitAction = context => {
      console.log("zone1 onExit", context);
      this.setState({tag: "Exit MIL"});
    };
    zone1.onChangeAction = contexts => {
      console.log("zone1 onChange", contexts);
      this.setState({tag: "Change in MIL"});
    };

    const zone2 = new RNEP.ProximityZone(2, "copa");
    zone2.onEnterAction = context => {
      console.log("zone2 onEnter", context);
    };
    zone2.onExitAction = context => {
      console.log("zone2 onExit", context);
    };
    zone2.onChangeAction = contexts => {
      console.log("zone2 onChange", contexts);
    };

    this.state = {
      tag: 'none',
      zones: [zone1, zone2]
    }

  }

  startScan() {
    RNEP.locationPermission.request().then(
      permission => {
        // `permission` will be one of RNEP.locationPermission.DENIED, .ALWAYS, or .WHEN_IN_USE
        console.log(`location permission: ${permission}`);

        if (permission !== RNEP.locationPermission.DENIED) {
          const credentials = new RNEP.CloudCredentials(
            "testproximity-a9k",
            "1681975deb0a7854d128763218d2207c"
          );

          this.setState({tag: credentials.appId});

          const config = {
            // modern versions of Android require a notification informing the user that the app is active in the background
            // if you don't need proximity observation to work in the background, you can omit the entire `notification` config
            //
            // see also: "Background support" section in the README
            notification: {
              title: "Exploration mode is on",
              text: "We'll notify you when you're next to something interesting.",
              //icon: 'my_drawable', // if omitted, will default to the app icon (i.e., mipmap/ic_launcher)

              // in apps targeting Android API 26, notifications must specify a channel
              // https://developer.android.com/guide/topics/ui/notifiers/notifications#ManageChannels
              channel: {
                id: "exploration-mode",
                name: "Exploration Mode"
              }
            }
          };

          RNEP.proximityObserver.initialize(credentials, config);
          RNEP.proximityObserver.startObservingZones(this.state.zones);
          // this.setState({tag: "finished"});
        }
      },
      error => {
        this.setState({tag: "Error when trying to obtain location permission"});
        console.error("Error when trying to obtain location permission", error);
      }
    );
  }
  
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome to React Native! {this.state.tag}</Text>
        <Text style={styles.instructions}>To get started, edit App.js</Text>
        <Text style={styles.instructions}>{instructions}</Text>

        <Button title='Scan' onPress={()=>this.startScan()}></Button>
      </View>
    );
  }
}

I put the start scan in button, because there is a issue that say it should be launched after app is ready.

How can I check if it is working?

@heypiotr
Copy link
Contributor

there is a issue that say it should be launched after app is ready.

I'm not sure I understand, what exactly does it say and where?

@evertonaleixo
Copy link
Author

In issue #11 . For this reason, I was starting just after click in the button.

@heypiotr
Copy link
Contributor

So your problem is the same as #11? Or now that you moved it into a button-click, do you have a different issue?

@evertonaleixo
Copy link
Author

It is not the same problem. In #11 the error is been presented to the developer, but I am can not view any error log, but the system is not find any beacon too. So, I want to know if there is any possibility to get a more verbose log to understand what is happening.

@heypiotr
Copy link
Contributor

Gotcha, I understand now ^_^

I checked your Cloud account and I can see that you have one beacon tagged as "mil", and no beacons tagged as "copa". The one beacon tagged as "mil" is a pretty old Estimote Beacon, which doesn't support our new Estimote Monitoring technology, and thus won't work with our Proximity SDKs.

Your "lemon", "beetroot", and "candy" beacons are a newer model, and these support Estimote Monitoring. You have to enable it, e.g., by connecting to these beacons via the Estimote iOS or Android app. Then, you can tag them, and your proximity zones should start working.

I'm going to close this issue, since it doesn't describe a problem with the react-native-proximity plugin. If you have more questions or problems getting Proximity up and running, worry not, I'll be happy to help you further on our forums: https://forums.estimote.com (:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants