diff --git a/.gitignore b/.gitignore index 1529277d99992ba79e43de7758ce93be8cf284d6..8c499494b2c35bca18796c6332712af01789ae32 100644 --- a/.gitignore +++ b/.gitignore @@ -188,4 +188,5 @@ package-lock.json .history android/.idea -android/build \ No newline at end of file +android/build +android/.gradle \ No newline at end of file diff --git a/android/.gradle/4.4/fileHashes/fileHashes.bin b/android/.gradle/4.4/fileHashes/fileHashes.bin index 214a41fb9fe6a129963150db829e99a410f7e4d8..ebc9922ec8cca3f1bdaf7a3251315985c2881ad1 100644 Binary files a/android/.gradle/4.4/fileHashes/fileHashes.bin and b/android/.gradle/4.4/fileHashes/fileHashes.bin differ diff --git a/android/.gradle/4.4/fileHashes/resourceHashesCache.bin b/android/.gradle/4.4/fileHashes/resourceHashesCache.bin index fa87a24899414469a68d22b62e4fb7a34bc9f5fb..f054bec96b165c8ee651a77c83bc762a15f7c5b9 100644 Binary files a/android/.gradle/4.4/fileHashes/resourceHashesCache.bin and b/android/.gradle/4.4/fileHashes/resourceHashesCache.bin differ diff --git a/android/.gradle/4.4/javaCompile/classAnalysis.bin b/android/.gradle/4.4/javaCompile/classAnalysis.bin index aea6eb43d50667366de7200bb3a8baa105c6c828..0dfb14d9786aaa8ffe2469583356f2237360e70a 100644 Binary files a/android/.gradle/4.4/javaCompile/classAnalysis.bin and b/android/.gradle/4.4/javaCompile/classAnalysis.bin differ diff --git a/android/.gradle/4.4/javaCompile/jarAnalysis.bin b/android/.gradle/4.4/javaCompile/jarAnalysis.bin index bef726e7163badc837e94006e249db9239e7b06b..6a433310a26102363c5cecad47efe51b48ccc9cf 100644 Binary files a/android/.gradle/4.4/javaCompile/jarAnalysis.bin and b/android/.gradle/4.4/javaCompile/jarAnalysis.bin differ diff --git a/android/.gradle/4.4/javaCompile/taskHistory.bin b/android/.gradle/4.4/javaCompile/taskHistory.bin index 00c31f57724568b64d31cefc01e01004572cf6e2..7b6f4af51ab16a6c275b54bab44700da3e665c98 100644 Binary files a/android/.gradle/4.4/javaCompile/taskHistory.bin and b/android/.gradle/4.4/javaCompile/taskHistory.bin differ diff --git a/android/.gradle/4.4/javaCompile/taskJars.bin b/android/.gradle/4.4/javaCompile/taskJars.bin index 6e30b744b3de289c68d3410812c04002a9d504db..73e6ddfbf89d4bc769a59c118a5fb5d6ea1d6068 100644 Binary files a/android/.gradle/4.4/javaCompile/taskJars.bin and b/android/.gradle/4.4/javaCompile/taskJars.bin differ diff --git a/android/.gradle/4.4/taskHistory/taskHistory.bin b/android/.gradle/4.4/taskHistory/taskHistory.bin index ef66e8d1987155cc661ce4401ae11a18a4af52b4..0b06e709bc30032fd678174b7a4830f7c90fed12 100644 Binary files a/android/.gradle/4.4/taskHistory/taskHistory.bin and b/android/.gradle/4.4/taskHistory/taskHistory.bin differ diff --git a/android/.gradle/buildOutputCleanup/cache.properties b/android/.gradle/buildOutputCleanup/cache.properties index 80e6674a2937e9f0c84d10be19af589b776584f3..d6a9efbbe39ab726698ea37ca3d347985f64fecb 100644 --- a/android/.gradle/buildOutputCleanup/cache.properties +++ b/android/.gradle/buildOutputCleanup/cache.properties @@ -1,2 +1,2 @@ -#Tue Mar 05 16:05:24 EET 2019 +#Mon Aug 12 14:22:42 IDT 2019 gradle.version=4.4 diff --git a/android/.gradle/buildOutputCleanup/outputFiles.bin b/android/.gradle/buildOutputCleanup/outputFiles.bin index 486eefe0dc65f65119160365573c86c04c74d204..ac4b33f10cc2878f09fa6b5d70d5c75cfc0cc7ce 100644 Binary files a/android/.gradle/buildOutputCleanup/outputFiles.bin and b/android/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java b/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java index 6588ce058b013f2ee0a87eec381377f3752a11f2..8fb5f010535baccf5814dead7be0df3a1a7da05b 100644 --- a/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java +++ b/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java @@ -18,6 +18,7 @@ import com.facebook.react.bridge.ReadableMap; import com.wix.reactnativenotifications.core.AppLifecycleFacade; import com.wix.reactnativenotifications.core.AppLifecycleFacadeHolder; import com.wix.reactnativenotifications.core.InitialNotificationHolder; +import com.wix.reactnativenotifications.core.NotificationIntentAdapter; import com.wix.reactnativenotifications.core.ReactAppLifecycleFacade; import com.wix.reactnativenotifications.core.notification.IPushNotification; import com.wix.reactnativenotifications.core.notification.PushNotification; @@ -62,8 +63,8 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements @Override public void onNewIntent(Intent intent) { - Bundle notificationData = intent.getExtras(); - if (notificationData != null) { + if (NotificationIntentAdapter.canHandleIntent(intent)) { + Bundle notificationData = intent.getExtras(); final IPushNotification notification = PushNotification.get(getReactApplicationContext().getApplicationContext(), notificationData); if (notification != null) { notification.onOpened(); diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java b/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java index d280fe7ebc6c2902fbc57e1f1308a583bfe67027..d7d32cdf54b9321513ddd793dc074f40741c97c5 100644 --- a/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java +++ b/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java @@ -14,6 +14,7 @@ import com.facebook.react.uimanager.ViewManager; import com.google.firebase.FirebaseApp; import com.wix.reactnativenotifications.core.AppLifecycleFacade; import com.wix.reactnativenotifications.core.AppLifecycleFacadeHolder; +import com.wix.reactnativenotifications.core.NotificationIntentAdapter; import com.wix.reactnativenotifications.core.notification.IPushNotification; import com.wix.reactnativenotifications.core.notification.PushNotification; import com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer; @@ -64,13 +65,11 @@ public class RNNotificationsPackage implements ReactPackage, AppLifecycleFacade. notificationsDrawer.onNewActivity(activity); Intent intent = activity.getIntent(); - if (intent != null) { + if (NotificationIntentAdapter.canHandleIntent(intent)) { Bundle notificationData = intent.getExtras(); - if (notificationData != null) { - final IPushNotification pushNotification = PushNotification.get(mApplication.getApplicationContext(), notificationData); - if (pushNotification != null) { - pushNotification.onOpened(); - } + final IPushNotification pushNotification = PushNotification.get(mApplication.getApplicationContext(), notificationData); + if (pushNotification != null) { + pushNotification.onOpened(); } } } diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java b/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java index 3af598b527721628574a51e56d25d83199f82c11..5a75a8ba940797808038c7b32cc1d2080d6fdada 100644 --- a/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java +++ b/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java @@ -18,4 +18,15 @@ public class NotificationIntentAdapter { public static Bundle extractPendingNotificationDataFromIntent(Intent intent) { return intent.getBundleExtra(PUSH_NOTIFICATION_EXTRA_NAME); } + + public static boolean canHandleIntent(Intent intent) { + if (intent != null) { + Bundle notificationData = intent.getExtras(); + if (notificationData != null && intent.hasExtra(PUSH_NOTIFICATION_EXTRA_NAME)) { + return true; + } + } + + return false; + } } diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index 2c970e940693c796645d42d7ef80c5cd1e691392..5e4e3d2ba9cd363d284d88d20984cd3bc6a8c0f1 100644 --- a/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -8,6 +8,8 @@ import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; +import android.os.Debug; +import android.util.Log; import com.facebook.react.bridge.ReactContext; import com.wix.reactnativenotifications.core.AppLaunchHelper; @@ -43,10 +45,6 @@ public class PushNotification implements IPushNotification { }; public static IPushNotification get(Context context, Bundle bundle) { - if (verifyNotificationBundle(bundle) == false) { - return null; - } - Context appContext = context.getApplicationContext(); if (appContext instanceof INotificationsApplication) { return ((INotificationsApplication) appContext).getPushNotification(context, bundle, AppLifecycleFacadeHolder.get(), new AppLaunchHelper()); @@ -62,14 +60,6 @@ public class PushNotification implements IPushNotification { mNotificationProps = createProps(bundle); } - private static boolean verifyNotificationBundle(Bundle bundle) { - if (bundle.getString("google.message_id") != null) { - return true; - } - - return false; - } - @Override public void onReceived() throws InvalidNotificationException { postNotification(null); @@ -168,13 +158,13 @@ public class PushNotification implements IPushNotification { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel(CHANNEL_ID, - CHANNEL_NAME, - NotificationManager.IMPORTANCE_DEFAULT); + CHANNEL_NAME, + NotificationManager.IMPORTANCE_DEFAULT); final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.createNotificationChannel(channel); notification.setChannelId(CHANNEL_ID); } - + return notification; }