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]: stale/wrong data in getPermissionAsync and requestPermission methods #1666

Open
2 of 3 tasks
mbardauskas opened this issue Mar 18, 2024 · 1 comment
Open
2 of 3 tasks

Comments

@mbardauskas
Copy link

mbardauskas commented Mar 18, 2024

What happened?

SDK returns wrong results for getPermissionAsync and requestPermission after user enables permissions via settings.

  const subscribe = async (): Promise<boolean> => {
    if (await OneSignal.Notifications.getPermissionAsync()) {
      if (!(await OneSignal.User.pushSubscription.getOptedInAsync())) {
        OneSignal.User.pushSubscription.optIn();
      }
      // ... other subscription requirements
      return true;
    } else {
      const fallbackToSettings = true;
      if (await OneSignal.Notifications.canRequestPermission()) {
        const enabled = await OneSignal.Notifications.requestPermission(fallbackToSettings);
        // ... other subscription requirements
        return enabled;
      } else {
        // ... lead to fallback view
      }
    }
  }

Am I using the SDK wrong?

Steps to reproduce?

1. install react-native-onesignal v5.1.0
2. launch app on Android
3. disable notifications via phone settings for the app
4. launch app again
5. call requestPermission with fallback to settings
6. press Settings in the permission prompt
7. enable notifications in the phone settings
8. go back to the app
9. requestPermission returns false, further calls to getPermissionAsync also returns false

What did you expect to happen?

when user enabled notifications in settings requestPermission should have returned true as per contract. Furthermore, getPermissionAsync should return true too

React Native OneSignal SDK version

5.1.0

Which platform(s) are affected?

  • iOS (not tested)
  • Android

Relevant log output

No errors in logs

Code of Conduct

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

@mbardauskas thank you for reaching out! We are looking into this.

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