OneSignal / OneSignal-Cordova-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Ionic, PhoneGap CLI, PhoneGap Build, Cordova, or Sencha Touch app with OneSignal. Supports Android, iOS, and Amazon's Fire OS platforms. https://onesignal.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: requestPermission with fallback true does not work correctly on Android 12 devices

kpturner opened this issue · comments

What happened?

If push notification permission has been denied, then when you use the requestPermission method passing true to fallback to the settings, the native settings prompt pops up. You can then give permission via the settings and return to the app. The requestPermission promise then resolves returning true (the user gave permission). However, on an Android 12 device (in this case a Nexus 6 running API 31) it always returns false.

To work around this, you can call hasPermission to get the correct value immediately after the requestPermission has resolved. However, if you call that method again for any other reason, it will always return false. Only by restarting the app will requestPermission return the correct value.

Steps to reproduce?

Use a Nexus 6 API 31 Android 12 emulator and test the requestPermission method with fallback enabled.

What did you expect to happen?

Should work as with later versions of Android.

OneSignal Cordova 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

Thank you for this report--we'll investigate further!