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

[Bug]: canRequestPermission is not working as expected #1698

Closed
2 of 3 tasks
Balaram-RJS opened this issue Apr 26, 2024 · 3 comments
Closed
2 of 3 tasks

[Bug]: canRequestPermission is not working as expected #1698

Balaram-RJS opened this issue Apr 26, 2024 · 3 comments

Comments

@Balaram-RJS
Copy link

Balaram-RJS commented Apr 26, 2024

What happened?

react-native-onesignal version 5.1.2 OneSignal.Notifications.canRequestPermission is not working as expected. Should it return true even if the user denied the native system prompt for android version 13. I am yet to check it for iOS.

Steps to reproduce?

doRegisterForRemoteNotifications = () => {
    OneSignal.Notifications.getPermissionAsync().then(granted => {
        OneSignal.Notifications.canRequestPermission().then(canrequest => {
            console.log('granted :: ' + granted);
            console.log('canrequest :: ' + canrequest);
            let doInit = Platform.select({
                android: () => {
                    OneSignal.Notifications.requestPermission(false);
                },
                ios: () => {
                    OneSignal.Notifications.requestPermission(false);
                },
                default: () => {},
            });
            if (granted === false && canrequest === true) {
                doInit();
            }
        });
    });
};

What did you expect to happen?

in the above code i would expect granted to be false and canrequest to be false if the user has denied the native system prompt.

React Native OneSignal SDK version

5.1.2

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Balaram-RJS
Copy link
Author

hi,
Could any one confirm whether this is the intended behaviour

@jennantilla
Copy link
Contributor

Hi @Balaram-RJS thank you for you patience!

canRequestPermission only returns true if the device has never been prompted for push notification permission. So if a user denies the prompt then it will return false.

Please let us know if you have any additional questions or concerns!

@Balaram-RJS
Copy link
Author

Hi @jennantilla ,

Thank you for taking out the time to reply,
but canRequestPermission is not working like that and if a user denies the system prompt it still returns true.
I have attached the device logs herewith.
device_log.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants