Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mikehardy opened this issue May 31, 2022 Discussed in #6282 · 14 comments
Labels
Keep Open avoids the stale bot platform: android plugin: messaging FCM only - ( messaging() ) - do not use for Notifications type: breaking change

Comments

@mikehardy
Copy link
Collaborator

Discussed in #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:

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 mikehardy added Workflow: Needs Review Pending feedback or review from a maintainer. help: android Needs help implementing a PR relating to Android code. help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. labels May 31, 2022
paulzhouentrust added a commit to paulzhouentrust/react-native-navigation that referenced this issue Jul 18, 2022
paulzhouentrust added a commit to paulzhouentrust/react-native-navigation that referenced this issue Jul 18, 2022
@fellipe-ribeiro
Copy link

Any news for this?

@mikehardy
Copy link
Collaborator Author

@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

@fellipe-ribeiro
Copy link

Fixed with react-native-permissions.
Thanks

@github-actions
Copy link

github-actions bot commented Dec 5, 2022

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 github-actions bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Dec 5, 2022
@ghost
Copy link

ghost commented Dec 5, 2022

react-native-permissions helps solve the issue

@github-actions github-actions bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label Dec 5, 2022
@mikehardy
Copy link
Collaborator Author

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

@github-actions
Copy link

github-actions bot commented Jan 6, 2023

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 github-actions bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Jan 6, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2023
@AlixH
Copy link

AlixH commented Jan 24, 2023

react-native-permissions helps solve the issue

How ?

@mikehardy
Copy link
Collaborator Author

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.

@AlixH
Copy link

AlixH commented Jan 24, 2023

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);
      }
    }

@mikehardy
Copy link
Collaborator Author

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?

zatteo added a commit to cozy/cozy-flagship-app that referenced this issue Aug 25, 2023
Removed react-native-firebase notification handling to use react-native-permissions for notifications. Support Android 13.

Related : invertase/react-native-firebase#6283
zatteo added a commit to cozy/cozy-flagship-app that referenced this issue Aug 25, 2023
Removed react-native-firebase notification handling to use react-native-permissions for notifications. Support Android 13.

Related : invertase/react-native-firebase#6283
@mikehardy mikehardy changed the title [📚] Support for Android 13 context permissions [📚] Support for Android 13 context permissions / or switch to react-native-permissions for all permissions work May 2, 2024
@mikehardy mikehardy removed the Type: Stale Issue has become stale - automatically added by Stale bot label May 2, 2024
@mikehardy
Copy link
Collaborator Author

Re-opening this but note that it is to track what I consider to be the real work:

  • alter documentation to recommend using react-native-permissions for all permissions-related work
  • remove the permissions code here

@mikehardy mikehardy reopened this May 2, 2024
@russellwheatley russellwheatley removed the help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. label Aug 13, 2024
@russellwheatley russellwheatley added plugin: messaging FCM only - ( messaging() ) - do not use for Notifications platform: android type: breaking change and removed help: android Needs help implementing a PR relating to Android code. Workflow: Needs Review Pending feedback or review from a maintainer. labels Aug 13, 2024
@russellwheatley
Copy link
Member

Agree with @mikehardy , RNFB ought to get out of the business of permissions when it is nowhere near comprehensive enough.

We have a potential breaking change incoming in the following year so I'm marking this as something to remove.

Copy link

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 github-actions bot added the Stale label Sep 10, 2024
@russellwheatley russellwheatley added Keep Open avoids the stale bot and removed Stale labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Keep Open avoids the stale bot platform: android plugin: messaging FCM only - ( messaging() ) - do not use for Notifications type: breaking change
Projects
None yet
Development

No branches or pull requests

4 participants