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

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

Open pierroo opened this issue 1 year ago • 1 comments

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?

  • [X] iOS
  • [X] Android

Relevant log output

No response

Code of Conduct

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

pierroo avatar Mar 02 '24 09:03 pierroo

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?

pierroo avatar Mar 02 '24 16:03 pierroo