react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

[📚] Support for Android 13 context permissions / or switch to react-native-permissions for all permissions work

Open mikehardy opened this issue 2 years ago • 12 comments

Discussed in https://github.com/invertase/react-native-firebase/discussions/6282

Originally posted by MicaelRodrigues May 31, 2022 With the upcoming [release](https://developer.android.com/about/versions/13/overview#timeline - late July) of Android Tiramisu apps will need to request permission to receive push notifications:

  • https://developer.android.com/about/versions/13/changes/notification-permission

It will start working similarly to IOS, that shows a system dialog for user choice. So, as a suggestion messaging().requestPermission should open that system dialog if the user hasn't granted/rejected permssions yet.

mikehardy avatar May 31 '22 12:05 mikehardy

Any news for this?

fellipe-ribeiro avatar Jul 27 '22 16:07 fellipe-ribeiro

@fellipe-ribeiro nope - it's open source, no need to ask for news, what you see is what you get --> https://medium.com/hackernoon/i-thought-i-understood-open-source-i-was-wrong-cf54999c097b

In the meantime, feel free to post a PR if this is important to your business, I'm traveling right now but have just enough time to collaborate on getting PRs in. I won't be able to do anything related to it for a month at least I think, and react-native-permissions should be considered your workaround until then

mikehardy avatar Jul 30 '22 22:07 mikehardy

Fixed with react-native-permissions. Thanks

fellipe-ribeiro avatar Aug 04 '22 21:08 fellipe-ribeiro

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Dec 05 '22 19:12 github-actions[bot]

react-native-permissions helps solve the issue

ghost avatar Dec 05 '22 19:12 ghost

Given the quality of react-native-permissions and that everyone (including myself!) has already had to handle this using it with android 13 out for a while... I think this actually calls for removing permissions from this library at the next breaking change

mikehardy avatar Dec 05 '22 21:12 mikehardy

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Jan 06 '23 09:01 github-actions[bot]

react-native-permissions helps solve the issue

How ?

AlixH avatar Jan 24 '23 13:01 AlixH

react-native-permissions helps solve the issue

How ?

It helps solve the issue because it is a complete, well-maintained package that supports the ability to interrogate current permission grant status on all useful permissions, and/or request permission from the user if the permission is not granted but you need it.

How could that not help solve a permission-related issue 🤔 ? It appears to be the canonical solution, in fact.

mikehardy avatar Jan 24 '23 13:01 mikehardy

react-native-permissions helps solve the issue

How ?

It helps solve the issue because it is a complete, well-maintained package that supports the ability to interrogate current permission grant status on all useful permissions, and/or request permission from the user if the permission is not granted but you need it.

How could that not help solve a permission-related issue 🤔 ? It appears to be the canonical solution, in fact.

I understand, but then it created a mix of library usage for notifications only. For iOS we do await messaging().requestPermission() and for Android we do await requestNotifications(['alert']). Is that even correct to have to following code ?

    if (authorizationStatus !== messaging.AuthorizationStatus.PROVISIONAL &&
        authorizationStatus !== messaging.AuthorizationStatus.AUTHORIZED ) {
      try {
        // requesting permission from user is required for iOS
        authorizationStatus = await messaging().requestPermission();
        if (Platform.OS === PLATFORM.ANDROID) {
          await requestNotifications(['alert']);
        }
       } catch ( error ) {
        console.error(error);
      }
    }
    if (authorizationStatus === messaging.AuthorizationStatus.AUTHORIZED || messaging.AuthorizationStatus.PROVISIONAL) {
      try {
        // Retrieve mobile token
        const fcmToken = await messaging().getToken();
        if ( fcmToken ) {
          this.token = fcmToken;
        }
      } catch ( error ) {
        console.error(error);
      }
    }

AlixH avatar Jan 24 '23 13:01 AlixH

My best recommendation is to use react-native-permissions for all permission related activity in all places, in all code. Then there is no mix. It is what I do in fact, in my work projects and what I think most people do?

mikehardy avatar Jan 24 '23 13:01 mikehardy