I have a React Native app with RN version "react-native": "0.72.7"
, and use react-native-notification
with version ^5.1.0
for my push notification service for both Android and iOS applications.
The push notification service works fine in iOS without any issues. The push notification service for the Android app has some problems.
I am dealing with a reloading issue for the Android versions 11 and above
. Following is the scenario for the bug.
Steps
- Open the Android app and keep it in the background
- Receive notification for the app and click on the notification from the notification center
- The app will open but the entire application gets reloaded
Accepted Criteria
- The app should not reload when clicking on the push notifications
Can anybody give me some sense into why this is happening?
2
Answers
As per the research I have done and the resolutions I went through, I managed to find a working solution for the issue in a
patch
for the latestreact-native-notification
.You can find the patch here. Install the patch and run the app again with your credentials it will work.
It is hard to suggest a solution without a code or some log messages.
Probably if you use
adb logcat
you could see some useful log messages that would help with this issue. But, I managed to find something related to your issue here.First, try updating your
targetSdkVersion
to 33, and see if it solves your problem. You can find it on yourandroid/app/build.gradle
file, for example:After this, re-compile your app and test it.
If it doesn’t help, you should try to make changes on the following files (– means you will remove it, + means you will add it):
/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
:/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java
After these changes, re-compile your app and test it.
These changes are not permanent, so to make them permanent you will need:
react-native-notifications
module by running:npm uninstall react-native-notifications
npm install git+https://github.com/yourUsername/YourForkNameHere
Hope it helps.