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

Question: callback of Radar.requestPermissions(background); #10

Closed oferRounds closed 7 years ago

oferRounds commented 7 years ago

Hi,

It says that you should can start tracking once the user has granted permission, but how can I tell when it’s done if I don’t have a callback?

nickpatrick commented 7 years ago

You can safely call Radar.startTracking() immediately after requesting permissions. Tracking will only start once the user grants permissions, and will not be started if the user has not granted permissions.

vadimshvetsov commented 5 years ago
export const startTracking = async (cleanerId) => {
  Radar.setPlacesProvider('none');
  Radar.setUserId(String(cleanerId));
  const status = await Radar.getPermissionsStatus();
  if (status !== 'GRANTED') {
    Radar.requestPermissions(true);
  }
  Radar.startTracking();
};

The problem in this code, that Radar.startTracking calls before user give permissions. And of course we can't track user with this code until he will relauch app with given permissions. There is nice to have a callback @nickpatrick Or maybe we can have other solution?

xutopia commented 3 years ago

Hi, I also found the lack of a callback in Radar.requestPermissions(background) (v3.0.6) to be insufficient for my use case. I resorted to using react-native-permissions which has more fine-tuned options when it comes to checking/requesting permissions and the subsequent callbacks to perform your other business logic. The repo also has great documentation and examples for how to use it. Hopefully, a combination of react-native-radar and react-native-permissions can satisfy your needs. Best of luck!

nickpatrick commented 3 years ago

Thanks, Tony. We're planning to add a callback or remove permissions helpers in favor of this lib (or similar) in the next major release. Appreciate the feedback!

On Wed, Jan 6, 2021 at 9:15 PM Tony Xu notifications@github.com wrote:

Hi, I also found the lack of a callback in Radar.requestPermissions(background) (v3.0.6) to be insufficient for my use case. I resorted to using react-native-permissions https://github.com/zoontek/react-native-permissions which has more fine-tuned options when it comes to checking/requesting permissions. The repo also has great documentation and examples for how to use it. Hopefully, a combination of react-native-radar and react-native-permissions can satisfy your needs. Best of luck!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/radarlabs/react-native-radar/issues/10#issuecomment-755838401, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB33WQ4WMSDUK5MTFM3T73SYUKKXANCNFSM4D5JCFXA .

--

Nick Patrick CEO and Co-Founder nick@radar.io