OneSignal / react-native-onesignal

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

[Bug]: promptForPushNotificationsWithUserResponse puts app in background for half a second for no reason #1658

Open pierroo opened 4 months ago

pierroo commented 4 months ago

What happened?

I just realized that OneSignal.promptForPushNotificationsWithUserResponse puts the app in background for half a second when it's called. I use "react-native-appstate-hook" to detect app state change, and if I comment out this function it no longer goes in background.

I never noticed it before, recent changes were updating onesignal from 4.5.1 to 4.5.2, and react native from 0.69.12 to 0.73.4

obviously this is problematic!

Steps to reproduce?

1- set app an app state listener
2- call promptForPushNotificationsWithUserResponse
3- notice that app goes to background when function is called

What did you expect to happen?

Leave my app foreground, obviously

React Native OneSignal SDK version

4.5.2

Which platform(s) are affected?

Relevant log output

No response

Code of Conduct

pierroo commented 4 months ago

Additional information: apparently onesignal is not at fault for putting app in background, even the

PermissionsAndroid.request(
            PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
          )

for react native will bring the app to background

does anyone know WHY and if there is a way to avoid it?