NMF-earth / nmf-app

Understand and reduce your carbon footprint 🌱 iOS & Android.
https://nmf.earth
GNU General Public License v3.0
488 stars 157 forks source link

Present PermissionsRequest in Notification screen #339

Closed PierreBresson closed 2 years ago

PierreBresson commented 2 years ago

Summary

Show PermissionsRequest component in Notification screen instead of opening settings with Linking.

NB: First to submit a valid PR, first to merge. Except if you already have merged some good code in this repo, I won’t assign any issue due to spam and beginners unable to complete a PR without a lot of help from my side.

BatDroid commented 2 years ago

As far as I'm concerned you can't show the permission pop up twice to a user once they've rejected. I also agree that just sending users to settings might not be a good UX, rather showing a popup saying : you've rejected before if you want you can go to settings and give permission manually (sth like that) & then two buttons yes/no sth

PierreBresson commented 2 years ago

@BatDroid indeed, you are right, you can only ask once with the native popup/dialog/prompt. The idea is to do the same as in the BarCodeScanScreen. When user open for the notification screen for the first time, he should see the native dialog with empty screen behind, like line 102 of BarCodeScanScreen :

  if (hasPermission === null) {
    return <View style={styles.container}></View>;
  }

And then if user has denied the authorization in the dialog show the component:

  if (!hasPermission) {
    return <PermissionsRequest type="notification" />;
  }

otherwise, show normal render.