OneSignal-Cordova-SDK icon indicating copy to clipboard operation
OneSignal-Cordova-SDK copied to clipboard

[Bug]: hasPermission() always initially returns false

Open terreng opened this issue 1 year ago • 3 comments

What happened?

window.plugins.OneSignal.Notifications.hasPermission() always returns false when called immediately within the Cordova deviceready event, even if permission has been granted. This method may need to be made a promise.

Steps to reproduce?

Observe that this code logs `false` even if permission is granted.

document.addEventListener("deviceready", function() {
  console.log(window.plugins.OneSignal.Notifications.hasPermission())
});


If you put this inside a short setTimeout then it returns the expected value (true if granted).

What did you expect to happen?

It should return true if permission has been granted.

OneSignal Cordova SDK version

5.0.1

Which platform(s) are affected?

  • [X] iOS
  • [X] Android

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

terreng avatar Sep 30 '23 02:09 terreng

Hello @terreng thank you so much for your patience. We're investigating this and will get back to you as soon as possible.

jennantilla avatar Nov 14 '23 20:11 jennantilla

Update?

kpturner avatar Jan 03 '24 14:01 kpturner

same here

aledebla03 avatar Feb 19 '24 12:02 aledebla03

Apologies that we missed updating this ticket! This issue should now be resolved by using the new method, getPermissionAsync. Please see our Migration Guide for more details. hasPermission is now deprecated.

Let us know if you have any questions or concerns!

jennantilla avatar Aug 15 '24 20:08 jennantilla