radarlabs / react-native-radar

React Native module for Radar, the leading geofencing and location tracking platform
https://radar.com
Apache License 2.0
170 stars 32 forks source link

The callback trackOnce() exists in module RNRadar, but only one callback may be registered to a function in a native module. #61

Closed atkit closed 5 years ago

atkit commented 5 years ago

Describe the bug trackOnceWithCompletionHandler is calling its callback more than once and it is not allowed to resolve Promise twise or more

To Reproduce

  1. tracking has been started already
  2. call trackOnce it will result with Promised callback
  3. a few seconds later it will try to resolve again
  4. See error

Expected behavior it needs to be called once

Screenshots image-1 image-2

Metadata (please complete the following information):

russellcullen commented 5 years ago

Thanks for the report. To clarify, you're seeing this error on Android as well? Mind sharing a code snippet of the JavaScript calling method?

atkit commented 5 years ago
    Radar.on("events", (data) => trackRadarEvent("events", data));
    Radar.on("location", (data) => trackRadarEvent("location", data));
    Radar.on("error", (data) => trackRadarEvent("error", data));
    Radar.trackOnce()
      .then((result) => {
        console.log(result);
      })
      .catch((err) => {
        console.log(err);
      });

startTracking was called before in previous session

russellcullen commented 5 years ago

@atkit We are able to reproduce locally and have a fix on the way. In short, the added main queue requirement

- (dispatch_queue_t)methodQueue {
    return dispatch_get_main_queue();
}

is causing our callback to be called twice. We will add a guard against this in our next release, which should be very soon. Thanks for the report and patience.