OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.56k stars 373 forks source link

[Bug]: Doesn't return to the app (crashes) if user rejects notification permission #1629

Open jose-gataca opened 8 months ago

jose-gataca commented 8 months ago

What happened?

After requesting permission on Android, if the permissions are rejected by the user, the rejection is not handled correctly by the sdk (either crash - if no fallback to settings - or kicked out of the app -if fallback to settings is set to true-).

Steps to reproduce?

1. Install v5.0.4 of the library on a react native application
2. Add the following code:
        const has = OneSignal.Notifications.hasPermission();
        const can = await OneSignal.Notifications.canRequestPermission();
        if (!has && can) {
            await AsyncStorageTool.storeData('permissions_requested', 'true');
            OneSignal.Notifications.requestPermission(false);
        }
3. Run on an Android Device
4. Reject notifications when the prompt is displayed

What did you expect to happen?

After the requestPermission (either to true or false), I would expect the application to run correctly without any push notifications. Instead, if fallbackToSettings is set to true, you are kicked out of the app if the notifications permissions are rejected. If it is set to false, then it plainly crashes.

React Native OneSignal SDK version

5.0.4

Which platform(s) are affected?

Relevant log output

No response

Code of Conduct

jennantilla commented 7 months ago

@jose-gataca thank your for reporting! We are looking into this.

MicaelaWaigel commented 7 months ago

+1