OneSignal / react-native-onesignal

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

[Bug]: Already initialized the OneSignal React-Native SDK #1521

Closed techday84 closed 5 months ago

techday84 commented 1 year ago

What happened?

E/OneSignal: Already initialized the OneSignal React-Native SDK.

This issue happens with 4.5.1 and 4.5.0

"react-native-onesignal": "^4.5.1", "react-native-share": "^8.1.0", "react-native-inappbrowser-reborn": "^3.7.0",

Steps to reproduce?

1. Install the packages.
2. Launch the app: npx react-native run-android
3. When the app changes from background to foreground or when you open a link with the inappbrowser or when you try to share a link with whatsApp. I think the error occurs every time the state of the app changes.
4. Note that android studio console error always shows  "E/OneSignal: Already initialized the OneSignal React-Native SDK."

What did you expect to happen?

I don't understand why it always get an error that it is already initialized when the app changes state or when you open things in the app that make it change the app state.

React Native OneSignal SDK version

4.5.1

Which platform(s) are affected?

Relevant log output

E/OneSignal: Already initialized the OneSignal React-Native SDK

Code of Conduct

nan-li commented 1 year ago

Hi @techday84,

Thanks for reaching out with your question. This error message can be safely ignored and we should probably change this to a VERBOSE level log instead of an ERROR.

This is why it is being logged so often: the SDK gets the activity/context info when an Android activity is resumed, but if the SDK already has it, it will output this log. Therefore, the SDK will log this whenever an activity is resumed and it already has the information needed.