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]: Android: requestPermission() doesn't resolve when permission is denied

terreng opened this issue · comments

What happened?

Unlike on iOS, requestPermission() doesn't resolve when the user denies the notification permission on Andriod (or if a prompt can't be shown).

On iOS, the method will resolve with either true or false.

On Android, the method only resolves if it's true.

Steps to reproduce?

Run the following:

window.plugins.OneSignal.Notifications.requestPermission(false).then(function (accepted) {
  console.log(accepted)
})

If you deny permission, observe that nothing is printed.

What did you expect to happen?

The method should always resolve with either true or false.

OneSignal Cordova SDK version

5.0.1

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

@terreng thank you for reporting! We'll work on incorporating this into a future release.

Thanks. This wasn't an issue before 5.x. It used to work. I hope that this can be corrected soon.

I can confirm this Issue! I wondered why my app didn't launch and the splash screen didn't disappear. It's really important for me that the function resolves correctly, so I can call OneSignal.User.pushSubscription.optIn(); at the right time.