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

Persistent UNKNOWN_ERROR after 2-3 minutes of trackOnce location updates #53

Closed phil-andrews closed 5 years ago

phil-andrews commented 5 years ago

I need a finer grained GPS location so instead of using background tracking I call trackOnce every 3-5 seconds to get the most recent coordinates of a users device. During testing on a real device while walking around outside, after about 2-3 minutes or 60 updates trackOnce starts throwing UNKNOWN_ERROR updates. It's always right around update number 60.

The error is persistent even through app restarts. I have to delete the app entirely than build and run again to get the error to go aways.

Steps to reproduce the behavior:

  1. Start clean project using rn typescript template.
  2. Follow SDK installation instructions from Radar docs.
  3. Install RN package and follow installation instructions.
  4. Call Radar from App.tsx in componentDidMount. =>
    setInterval(() => {
      Radar.trackOnce().then((result: any) => {
        console.log(result)
      }).catch((err: any) => {
        console.log(err)
      });
    }, 3000)

Expected behavior A normal location update on calling trackOnce.

"react-native": "0.57.8", "react-native-radar": "^2.1.2" emulator XR xCode 10

russellcullen commented 5 years ago

Yes, this is because of rate limits you are hitting, 60 requests per hour per user, details here - https://radar.io/documentation/sdk#ios-foreground

I would suggest not using Radar for this type of high power and high frequency use case. The SDK really shines when reacting to changes in user context like entering or exiting geofences, places, etc. You can read more about Radar here - https://radar.io/documentation

phil-andrews commented 5 years ago

Something other than ERROR_UNKNOWN would be pretty useful in that situation. It's difficult to decipher where that rate limit applies to the trackOnce call within the SDK as I wasn't using the REST API. I'm not sure how I would have found it without posting here.

russellcullen commented 5 years ago

Yeah, looks like that error string is simply missing from the iOS error codes on the React Native side. We will add this in the next release, thanks for the heads up!

Since the React Native module uses the native modules under the hood, the rate limits for trackOnce documented here still apply: https://radar.io/documentation/sdk#ios-foreground

phil-andrews commented 5 years ago

Thanks man. I appreciate the quick responses.