Can't open Application when touch in Notification android
In version 1.2.52, it have this bug. You can fix it
Go to PushNotification.java in folder: react-native-notifications/android/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
Add this function in end class PushNotification
protected void launchOrResumeApp() {
final Intent intent = mAppLaunchHelper.getLaunchIntent(mContext);
mContext.startActivity(intent);
}
After, add to call this function in digestNotification function, like:
if (!mAppLifecycleFacade.isReactInitialized()) {
setAsInitialNotification();
launchOrResumeApp(); // call function
return;
}
and add to call in function dispatchUponVisibility, like:
protected void dispatchUponVisibility() {
mAppLifecycleFacade.addVisibilityListener(getIntermediateAppVisibilityListener());
launchOrResumeApp(); // // call function
}
Hope it help you.
This solution works if the app is not closed. If the app is closed, then tapping on the notification will not open the app and the notification will disappear from the notification center.
This solution works if the app is not closed. If the app is closed, then tapping on the notification will not open the app and the notification will disappear from the notification center. you can handle in JS code with Opened function to direction to screen that you need.
@huyvm I'm sorry, but your answer is a bit vague and I can't quite get a grasp on the solution. Could you please elaborate on the part where you say:
you can handle in JS code with Opened function to direction to screen that you need.
?
Thank you very much
Follow this code, in JS code:
NotificationsAndroid.setNotificationOpenedListener((notification) => {
console.log("Notification opened by device user", notification.getData());
// direct to screen
});
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.
The issue has been closed for inactivity.