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]: OneSignal.Notifications.canRequestPermission not working [Android 11, Android 12] #1622

Closed
2 of 3 tasks
johannessachse opened this issue Jan 5, 2024 · 1 comment
Closed
2 of 3 tasks

Comments

@johannessachse
Copy link

johannessachse commented Jan 5, 2024

What happened?

I tried to ask for notification permission but OneSignal.Notifications.canRequestPermission does not return anything.

Steps to reproduce?

1. Disable push notifications in system settings
2. Request permission
3. Receiving no result or permission dialog

            const canRequest = await OneSignal.Notifications.canRequestPermission();
            console.log(canRequest); // log: true

            console.log('request start'); // log: request start
            const result = await OneSignal.Notifications.requestPermission(false);
            console.log('request end'); // no log received


For your information:
On iOS and Android 13+ everything works fine

What did you expect to happen?

I expect that the permission dialog opens and a boolean is returned.

React Native OneSignal SDK version

Release 5.0.4

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
@johannessachse johannessachse changed the title [Bug: Android 11 + 12]: OneSignal.Notifications.canRequestPermission not working [Bug]: OneSignal.Notifications.canRequestPermission not working [Android 11, Android 12] Jan 5, 2024
@jennantilla
Copy link
Contributor

Hi @johannessachse thank you for your patience!

On Android 12 and lower notifications were accepted silently/automatically. This changed in Android 13 where granting permission become required. Therefore, prompting only happens for Android 13 or newer devices. canRequestPermission currently returns true for Android 12 and lower although prompting will actually occur. We can look into adding some additional documentation of this behavior to clarify.

Let me know if you have any additional questions or concerns!

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