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]: hasPermission() always initially returns false #925

Closed
3 tasks done
terreng opened this issue Sep 30, 2023 · 4 comments
Closed
3 tasks done

[Bug]: hasPermission() always initially returns false #925

terreng opened this issue Sep 30, 2023 · 4 comments

Comments

@terreng
Copy link

terreng commented Sep 30, 2023

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?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jennantilla
Copy link
Contributor

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

@kpturner
Copy link

kpturner commented Jan 3, 2024

Update?

@aledebla03
Copy link

same here

@jennantilla
Copy link
Contributor

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!

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

4 participants