From 87eafa074b2652fd13459863af218517481da6e9 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Fri, 30 Sep 2016 17:44:04 -0400 Subject: [PATCH] handle null point bug --- android/react-native-fcm.iml | 48 +++++++++---------- .../evollu/react/fcm/FIRMessagingModule.java | 11 +++-- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/android/react-native-fcm.iml b/android/react-native-fcm.iml index 17bc181..be7ba28 100644 --- a/android/react-native-fcm.iml +++ b/android/react-native-fcm.iml @@ -101,35 +101,35 @@ - - - - - - - - - - - - - - - - - + + - + - - - - - + + + + + + + + + - + + + + + + + + + + + + \ No newline at end of file diff --git a/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java b/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java index 7878692..6f62c54 100644 --- a/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java +++ b/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java @@ -51,6 +51,11 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li @ReactMethod public void getInitialNotification(Promise promise){ + Activity activity = getCurrentActivity(); + if(activity == null){ + promise.resolve(null); + return; + } promise.resolve(parseIntent(getCurrentActivity().getIntent())); } @@ -136,14 +141,14 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li RemoteMessage message = intent.getParcelableExtra("data"); WritableMap params = Arguments.createMap(); if(message.getData() != null){ - Map data = message.getData(); + Map data = message.getData(); Set keysIterator = data.keySet(); for(String key: keysIterator){ params.putString(key, (String) data.get(key)); } - sendEvent("FCMNotificationReceived", params); - abortBroadcast(); } + sendEvent("FCMNotificationReceived", params); + abortBroadcast(); } } -- 2.26.2