diff --git a/android/react-native-fcm.iml b/android/react-native-fcm.iml index fa71af8096a2e0e9aa6cc118bb881f468a6f40eb..17bc181efa4dd31c7f4e2a87eb5f0ad299054898 100644 --- a/android/react-native-fcm.iml +++ b/android/react-native-fcm.iml @@ -120,8 +120,8 @@ - + diff --git a/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java b/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java index cbc7bc678b70fb8af91dcbbd4e11a4531f3d1f89..cb2faa73900bedfa01b89ab9e982b40623b78614 100644 --- a/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java +++ b/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java @@ -159,7 +159,6 @@ public class FIRLocalMessagingHelper { Intent intent = new Intent(mContext, intentClass); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtras(bundle); - intent.putExtra("localNotification", true); intent.setAction(bundle.getString("click_action")); int notificationID = bundle.containsKey("id") ? bundle.getString("id", "").hashCode() : (int) System.currentTimeMillis(); 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 a26c6ea70d9d8e8efb2ad8fa5348705dca9e247b..7878692aec9fca17c9218378335cd60ba47914c0 100644 --- a/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java +++ b/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java @@ -157,7 +157,7 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li @Override public void onReceive(Context context, Intent intent) { if (getReactApplicationContext().hasActiveCatalystInstance()) { - sendEvent("FCMLocalNotificationReceived", Arguments.fromBundle(intent.getExtras())); + sendEvent("FCMNotificationReceived", Arguments.fromBundle(intent.getExtras())); abortBroadcast(); } } @@ -206,8 +206,6 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li @Override public void onNewIntent(Intent intent){ - Bundle bundle = intent.getExtras(); - Boolean isLocalNotification = bundle != null && bundle.getBoolean("localNotification", false); - sendEvent(isLocalNotification ? "FCMLocalNotificationReceived" : "FCMNotificationReceived", parseIntent(intent)); + sendEvent("FCMNotificationReceived", parseIntent(intent)); } } diff --git a/index.js b/index.js index 14203c22083f1ae6afaa7c31613fbca5ddb47923..0d29f007408564a8fb4cd58b7ef2441e5224fcfc 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,7 @@ import {NativeModules, DeviceEventEmitter, Platform} from 'react-native'; const eventsMap = { refreshToken: 'FCMTokenRefreshed', - notification: 'FCMNotificationReceived', - localNotification: 'FCMLocalNotificationReceived' + notification: 'FCMNotificationReceived' }; const RNFIRMessaging = NativeModules.RNFIRMessaging; @@ -57,6 +56,9 @@ FCM.getBadgeNumber = () => { FCM.on = (event, callback) => { const nativeEvent = eventsMap[event]; + if (!nativeEvent) { + throw new Error('FCM invalid event'); + } const listener = DeviceEventEmitter.addListener(nativeEvent, callback); return function remove() {