diff --git a/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index 54a5fb83c..d617dcf26 100644 --- a/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -8,6 +8,7 @@ import android.content.Intent; import android.os.Build; import android.os.Bundle; +import android.util.Log; import com.facebook.react.bridge.ReactContext; import com.wix.reactnativenotifications.core.AppLaunchHelper; @@ -18,6 +19,7 @@ import com.wix.reactnativenotifications.core.JsIOHelper; import com.wix.reactnativenotifications.core.NotificationIntentAdapter; +import static com.wix.reactnativenotifications.Defs.LOGTAG; import static com.wix.reactnativenotifications.Defs.NOTIFICATION_OPENED_EVENT_NAME; import static com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_EVENT_NAME; import static com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_BACKGROUND_EVENT_NAME; @@ -207,9 +209,12 @@ private void notifyReceivedBackgroundToJS() { private void notifyOpenedToJS() { Bundle response = new Bundle(); - response.putBundle("notification", mNotificationProps.asBundle()); - - mJsIOHelper.sendEventToJS(NOTIFICATION_OPENED_EVENT_NAME, response, mAppLifecycleFacade.getRunningReactContext()); + try { + response.putBundle("notification", mNotificationProps.asBundle()); + mJsIOHelper.sendEventToJS(NOTIFICATION_OPENED_EVENT_NAME, response, mAppLifecycleFacade.getRunningReactContext()); + } catch (NullPointerException e) { + Log.e(LOGTAG, "notifyOpenedToJS: Null pointer exception"); + } } protected void launchOrResumeApp() {