-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
checkNotifications returns "denied" in all cases on Android 13 #714
Comments
Hi. This is not a bug, check the Android permission flow. Consider this flow:
It works on all OS and have a good enough UX. |
@zoontek but that's the point, what you are suggesting is now impossible on Android 13. on iOS and Android prior to 13 checkNotifications() method returns "granted", "denied" or "blocked". But on Android 13 it only returns either "granted" or "denied" - "blocked" is never returned even when it's actually blocked.
when notification access is already blocked, on Android 13 this returns
and on Android 12 and iOS this returns
|
Did you find a solution to this? I suspect it might be related to this, but I can't make it work even with adding the permission https://developer.android.com/develop/ui/views/notifications/notification-permission |
any help on this? |
Reading the first line of the Android documentation @nicwise posted:
There's no issue here. EDIT: More infos about the runtime flow, which is the same for all Android runtime permissions: #828 (comment) |
Hi @zoontek, sorry to keep asking about this. I see there are at least 3 duplicate issues about it! Are we being really stupid? Here is our problem, using your flow for Android >=13 ...
FINE. We'll use
FINE.
NOT FINE.
NOT FINE. Thanks for your patience :) |
@chichilatte OK, let's start again from zero.
This is the runtime permission flow on Android: So, let's recap:
All good.
Yes, but iOS and Android < 13 could. You can improve their UX over Android >= 13 and its not-so-good runtime permission API (which makes this impossible).
Exactly like all the others runtime permissions on Android, since Android 6. Have you tried The Even simpler, if you check the But if no one seems to understand it, I will simply return When I give this kind of scenario, keep in mind that it's a solution to easily handle all permissions, on all platforms given their respectives limitations.
I hope this is clear. |
Here, it will be easier for everyone: https://github.com/zoontek/react-native-permissions/releases/tag/4.0.1
Also, it makes less sense since you might see a request permission button on Android < 13, but it will never be able to prompt you, you will have to redirect to settings to update the value. |
Wow, thanks for replying so thoroughly @zoontek, truly appreciated. So here's what i understand from all you've said in this thread, and from the Android flow diagram... On Android >= 13:
From these two points you can conclude: On Android >=13 we cannot show the user a message explaining why they should grant permission (aka the rationale) before we open the runtime system permission dialog. Which is weird, because the Android docs recommend we do show a rationale. My use case is asking for notifications permission only once, at a specific time after install. That's not a use case Android envisaged, so the best solution for me is probably...
That's as clear as I can be. If I'm still mistaken about anything then i must have gone mad, my apologies 🤣 🔫 |
Personally it like that Android < 13 behaves differently (and more rationally). And it would be a breaking change. A difficult change to get your head around. I'm more confused by how Android >= 13 is not able to say if permission has been blocked before we request permission. |
Exactly, and now with 4.0.1 it's the same on Android < 13.
What it says is actually this:
So, now, let me explain how Before Android 11, you could request permissions as much as you want:
Since Android 11, this is a bit different:
Keep that in mind. Now, let's investigate on This function is called before the native
So, how to determine if a permission is
You can't know 🤷🏻♂️ That's also the reason the builtin And before you ask me, I know that at some time some developers saved already requested (and blocked) permissions in
Actually no, the returned type always has been
This is how every runtime permissions on Android works. I deeply encourage you to try checking / requesting other ones (you have the example app for that).
As it now aligns to the android permission flow / all the others permissions check, I think it will be easier for everyone 🙂 |
Ahhh. So, correct me if I'm wrong, on Android >= 13 we can have this fairly common flow...
The next time the situation comes the user will go through the same flow again. Even though they said "Don't Allow" the first time. Since Android 11 this can happen only twice. Further repetitions of the flow will look like this...
As far as i can see, if you want the flow to happen only once then you must store the fact that the user blocked permission. And in doing that you may be ignoring the user's wish to I have to say @zoontek you're doing an incredible job with this thicket of detail. It seems to me the Android permission system is so complex it's basically broken! |
It's a compromise indeed. I chose to go for the poorer UX and support "Ask next time" as storing the value is still possible on your side, you accept to break it. And yes, Android permission system is broken 🥲 |
Just to be clear for anybody who sees this thread... On Android >=13 you cannot display a rationale message before opening the system's permission request prompt.This is because Android does not let you know if permission is There is a workaround where you store the status returned by (happy to edit this if needs correcting) EditYou can pass a
|
You can, it should appear before the second |
Oh i didn't even see the |
I think they though "Maybe if we allow devs to know that the user has refused once, and they can beg the user before re-doing it, it will be a nice experience" 😅 |
Thank you guys so much. It's super clear :D |
Bug summary
When checking and requesting notifications permission on Android 13, there is now no way to tell whether you should try requesting notifications permission or take user to settings screen, unless you manually store the amount of failed attempts to request permission, because the status is always "denied" no matter if it's first launch or if user clicked "Don't allow" twice or disabled it manually after allowing it.
Library version
3.6.1
Environment info
Steps to reproduce
Reproducible sample code
i did set targetSdkVersion to 33
The text was updated successfully, but these errors were encountered: