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]: Has Permission showing false when it's not. #948

Closed
2 of 3 tasks
RZR666 opened this issue Dec 7, 2023 · 2 comments
Closed
2 of 3 tasks

[Bug]: Has Permission showing false when it's not. #948

RZR666 opened this issue Dec 7, 2023 · 2 comments

Comments

@RZR666
Copy link

RZR666 commented Dec 7, 2023

What happened?

let permission = window.plugins.OneSignal.Notifications.hasPermission();

I can see that I have push notifications enabled but the above returns false.

"@angular/core": "^15.2.8",
"@ionic/angular": "^7.0.4",
"cordova-android": "11.0.0",
"onesignal-cordova-plugin": "^5.0.3",

Steps to reproduce?

initOneSignal()
{
   window.plugins.OneSignal.initialize(oneSignalAppId);
}

enablePush()
{
this.androidPermissions.checkPermission(PERMISSION.POST_NOTIFICATIONS).then(
          result => this.requestPushPermission(result.hasPermission),
          err => this.androidPermissions.requestPermission(PERMISSION.POST_NOTIFICATIONS));
}

requestPushPermission(hasPermission)
{
  if (hasPermission)
  {
    this.optInToPush();
  }
}

optInToPush()
{
    window.plugins.OneSignal.User.pushSubscription.optIn();

    let permission = window.plugins.OneSignal.Notifications.hasPermission();
    console.log(permission);
}

What did you expect to happen?

It should show true.

OneSignal Cordova SDK version

5.0.3

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
@RZR666
Copy link
Author

RZR666 commented Dec 7, 2023

So it worked by going through,

window.plugins.OneSignal.Notifications.requestPermission(true).then((accepted: boolean) => {

but it's weird it didn't work the above way, since it had actually also enabled push permission.

@jennantilla
Copy link
Contributor

Hi @RZR666 apologies for the delay. hasPermission has been deprecated and replaced with getPermissionAsync which will return the correct value. Please update to the latest SDK and let us know if you are still facing any issues.

Thanks!

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