Closed billnbell closed 2 years ago
This only happens when the app is stopped/not running and the user clicks a push notification to open the app. What happens is the app Splash screen just sites there and when hide() fires it says it is not initialized.
But is is visible? If not, just catch and ignore the promise rejection
It is not visible yet. As you can see I am doing a try/catch.
When the react-native code hits RNBootSplash.hide({ fade: true }); the Android process has not yet hit, RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); So it does not see visibility yet, since RNBootSplash is not loaded, and the catch() is fired.
But in about 50 ms, the RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); is hit, and the bootstrap runs. Then react-native never knows about it, and the screen never hides.
This only happens on Push Notification clicking when the app is CLOSED/QUIT/Shutdown in Android. Adding the setTimeout to hide works perfectly, but I don't like it. Is there a way to synchronously get the
RNBootSplash.init(R.drawable.bootsplash, MainActivity.this);
to fire before react native starts?
Update to v4.x, it should fix the issue.
OK I like 4.x since it moves to one Activity. However by setting 31 (Android 12) I am having several errors in the build. It seems the issue in most packages is not having android:exported="true"
- is there a way to patch <Activities and add android:exported="true"
as I build? That will get me a lot farther.
I will try this:
<receiver android:name="<name_of_the_entry>"
android:exported="false or true"
tools:node="merge" />
@billnbell First, check if the libraries have an update for compatibility with Android 12. If this cannot be done, check this: https://stackoverflow.com/a/68866812/5529224
@billnbell Did you succeeded? Does the issue still exists?
I installed it. Will do more testing.
@zoontek is it possible to add custom style for 3.2.6 version for android ? (currently version of react native 0.64)
It works in latest version.
Cool! I'm closing this then
Bug summary
We are using hide in App.tsx wrapped in a useAsyncEffect(). This fires before the code in onCreate fires and we get an error. I wrapped it in a setTimeout() and I think this may work. But what is the best way to do this?
This only happens when the app is stopped/not running and the user clicks a push notification to open the app. What happens is the app Splash screen just sites there and when hide() fires it says it is not initialized.
In MainActivity I have the following. Question, can we move this earlier to fire on a push notification click?
Here is my AndroidManifest.xml.
Library version
3.2.6
Environment info
Steps to reproduce
Reproducible sample code