react-native-onesignal icon indicating copy to clipboard operation
react-native-onesignal copied to clipboard

[Bug]: fallback to settings prompt is shown when calling requestPermission(false)

Open Redn4s opened this issue 1 year ago • 3 comments

What happened?

When requesting the push permission after the user already declined push permissions, the "Open settings" prompt is still shown even when I pass false when calling requestPermission().

OneSignal.Notifications.requestPermission(false) // Still shows the "Open settings" alert

Steps to reproduce?

1. Install v5.0.4 of react-native-onesignal
2. Call `requestPermission(false)`
3. Decline the push permission
4. Call `requestPermission(false)` again
5. The "Open settings" prompt is shown

What did you expect to happen?

I expect the "Open settings" prompt not to show up when I call requestPermission(false) after the user already declined push permissions.

React Native OneSignal SDK version

5.0.4

Which platform(s) are affected?

  • [X] iOS
  • [ ] Android

Relevant log output

No response

Code of Conduct

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

Redn4s avatar Dec 11 '23 13:12 Redn4s

I was also getting this error and the problem was that I was calling requestPermission() twice inside the codebase. calling it only once solved the problem.

andrewdazs avatar Dec 18 '23 23:12 andrewdazs

I was also getting this error and the problem was that I was calling requestPermission() twice inside the codebase. calling it only once solved the problem.

I have called it just once still same issue

BijuDey avatar Feb 19 '24 13:02 BijuDey

OneSignal.Notifications.canRequestPermission().then(can => {
  if (can) OneSignal.Notifications.requestPermission(false)
})

solves this problem

unknwngera avatar Mar 15 '24 17:03 unknwngera