[Bug]: stale/wrong data in getPermissionAsync and requestPermission methods
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)
- [X] Android
Relevant log output
No errors in logs
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@mbardauskas thank you for reaching out! We are looking into this.
any update? I have a similar problem. after granting the notification permission, the correct data does not come unless I exit the app and log in. @jennantilla
@MuazzezA @jennantilla Not sure, but this might be related to #1726
Hello everyone! Thanks for your patience on this. Can you please try updating to Release 5.2.3 and let us know if the issue still occurs? Thanks!