diff --git a/android/app/build.gradle b/android/app/build.gradle
index d2c1944a9d736ee97bf784c49458f496284dde01..9ea834b292ae7390634cdaf1fc734d26bdf48e96 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -17,6 +17,25 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
+ testOptions {
+ unitTests.all { t ->
+ reports {
+ html.enabled true
+ }
+ testLogging {
+ events "PASSED", "SKIPPED", "FAILED", "standardOut", "standardError"
+ }
+ afterSuite { desc, result ->
+ if (!desc.parent) { // will match the outermost suite
+ def output = " ${result.resultType} (${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped) "
+ def repeatLength = output.length()
+ println '\n\n' + ('-' * repeatLength) + '\n' + output + '\n' + ('-' * repeatLength) + '\n'
+
+ println "see report at file://${t.reports.html.destination}/index.html"
+ }
+ }
+ }
+ }
}
dependencies {
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index ffef75f236e30d1e2d4b99280dcb04964b70afd9..b6dad7c76ffdde4c620b013f501f8c97055b7781 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -4,7 +4,7 @@
package="com.wix.reactnativenotifications">
+ android:name=".fcm.FcmInstanceIdListenerService">
@@ -30,7 +30,7 @@
diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/Defs.java b/android/app/src/main/java/com/wix/reactnativenotifications/Defs.java
index 26a8b7a0383c642fa3e17102d582e502d05646eb..ec7f72ace0d84f425c645e00ae5331df5dbac3a2 100644
--- a/android/app/src/main/java/com/wix/reactnativenotifications/Defs.java
+++ b/android/app/src/main/java/com/wix/reactnativenotifications/Defs.java
@@ -2,7 +2,6 @@ package com.wix.reactnativenotifications;
public interface Defs {
String LOGTAG = "ReactNativeNotifs";
- String GCM_SENDER_ID_ATTR_NAME = "com.wix.reactnativenotifications.gcmSenderId";
String TOKEN_RECEIVED_EVENT_NAME = "remoteNotificationsRegistered";
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 8fb5f010535baccf5814dead7be0df3a1a7da05b..61dddec58ac144b6810d6df7a94bdd474f501bdf 100644
--- a/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
+++ b/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
@@ -15,7 +15,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
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;
@@ -25,9 +24,7 @@ import com.wix.reactnativenotifications.core.notification.PushNotification;
import com.wix.reactnativenotifications.core.notification.PushNotificationProps;
import com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer;
import com.wix.reactnativenotifications.core.notificationdrawer.PushNotificationsDrawer;
-import com.wix.reactnativenotifications.gcm.FcmInstanceIdRefreshHandlerService;
-
-import com.google.firebase.FirebaseApp;
+import com.wix.reactnativenotifications.fcm.FcmInstanceIdRefreshHandlerService;
import static com.wix.reactnativenotifications.Defs.LOGTAG;
@@ -50,7 +47,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
@Override
public void initialize() {
Log.d(LOGTAG, "Native module init");
- startGcmIntentService(FcmInstanceIdRefreshHandlerService.EXTRA_IS_APP_INIT);
+ startFcmIntentService(FcmInstanceIdRefreshHandlerService.EXTRA_IS_APP_INIT);
final IPushNotificationsDrawer notificationsDrawer = PushNotificationsDrawer.get(getReactApplicationContext().getApplicationContext());
notificationsDrawer.onAppInit();
@@ -75,7 +72,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
@ReactMethod
public void refreshToken() {
Log.d(LOGTAG, "Native method invocation: refreshToken()");
- startGcmIntentService(FcmInstanceIdRefreshHandlerService.EXTRA_MANUAL_REFRESH);
+ startFcmIntentService(FcmInstanceIdRefreshHandlerService.EXTRA_MANUAL_REFRESH);
}
@ReactMethod
@@ -115,7 +112,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
promise.resolve(new Boolean(hasPermission));
}
- protected void startGcmIntentService(String extraFlag) {
+ protected void startFcmIntentService(String extraFlag) {
final Context appContext = getReactApplicationContext().getApplicationContext();
final Intent tokenFetchIntent = new Intent(appContext, FcmInstanceIdRefreshHandlerService.class);
tokenFetchIntent.putExtra(extraFlag, true);
diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdListenerService.java
similarity index 75%
rename from android/app/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java
rename to android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdListenerService.java
index 2456913ea09c931e99aa29550c9a61ac0c07c237..061b7331980f53d4947510165e44f0c65c6121d4 100644
--- a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdListenerService.java
+++ b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdListenerService.java
@@ -1,4 +1,4 @@
-package com.wix.reactnativenotifications.gcm;
+package com.wix.reactnativenotifications.fcm;
import android.os.Bundle;
import android.util.Log;
@@ -8,12 +8,10 @@ import com.google.firebase.messaging.RemoteMessage;
import com.wix.reactnativenotifications.core.notification.IPushNotification;
import com.wix.reactnativenotifications.core.notification.PushNotification;
-import java.util.Map;
-
import static com.wix.reactnativenotifications.Defs.LOGTAG;
/**
- * Instance-ID + token refreshing handling service. Contacts the GCM to fetch the updated token.
+ * Instance-ID + token refreshing handling service. Contacts the FCM to fetch the updated token.
*
* @author amitd
*/
@@ -22,14 +20,14 @@ public class FcmInstanceIdListenerService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage message){
Bundle bundle = message.toIntent().getExtras();
- Log.d(LOGTAG, "New message from GCM: " + bundle);
+ Log.d(LOGTAG, "New message from FCM: " + bundle);
try {
final IPushNotification notification = PushNotification.get(getApplicationContext(), bundle);
notification.onReceived();
} catch (IPushNotification.InvalidNotificationException e) {
- // A GCM message, yes - but not the kind we know how to work with.
- Log.v(LOGTAG, "GCM message handling aborted", e);
+ // An FCM message, yes - but not the kind we know how to work with.
+ Log.v(LOGTAG, "FCM message handling aborted", e);
}
}
}
diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdRefreshHandlerService.java b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdRefreshHandlerService.java
similarity index 73%
rename from android/app/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdRefreshHandlerService.java
rename to android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdRefreshHandlerService.java
index 8270ad68e724f6463bee122fb17462c0a6a18adb..dd2cc9a210c73c506f45ddb0e0311067dfd19931 100644
--- a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/FcmInstanceIdRefreshHandlerService.java
+++ b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdRefreshHandlerService.java
@@ -1,4 +1,4 @@
-package com.wix.reactnativenotifications.gcm;
+package com.wix.reactnativenotifications.fcm;
import android.app.IntentService;
import android.content.Intent;
@@ -14,17 +14,17 @@ public class FcmInstanceIdRefreshHandlerService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
- IFcmToken gcmToken = FcmToken.get(this);
- if (gcmToken == null) {
+ IFcmToken fcmToken = FcmToken.get(this);
+ if (fcmToken == null) {
return;
}
if (intent.getBooleanExtra(EXTRA_IS_APP_INIT, false)) {
- gcmToken.onAppReady();
+ fcmToken.onAppReady();
} else if (intent.getBooleanExtra(EXTRA_MANUAL_REFRESH, false)) {
- gcmToken.onManualRefresh();
+ fcmToken.onManualRefresh();
} else {
- gcmToken.onNewTokenReady();
+ fcmToken.onNewTokenReady();
}
}
}
diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java
similarity index 94%
rename from android/app/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java
rename to android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java
index 44c8ec6dffe65f122ad21a4f51c2438fd2f11a31..04c275590f447a10a4e724713a3fd21c3e850736 100644
--- a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/FcmToken.java
+++ b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java
@@ -1,4 +1,4 @@
-package com.wix.reactnativenotifications.gcm;
+package com.wix.reactnativenotifications.fcm;
import android.content.Context;
import android.util.Log;
@@ -29,8 +29,8 @@ public class FcmToken implements IFcmToken {
public static IFcmToken get(Context context) {
Context appContext = context.getApplicationContext();
- if (appContext instanceof INotificationsGcmApplication) {
- return ((INotificationsGcmApplication) appContext).getFcmToken(context);
+ if (appContext instanceof INotificationsFcmApplication) {
+ return ((INotificationsFcmApplication) appContext).getFcmToken(context);
}
return new FcmToken(appContext);
}
diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/IFcmToken.java b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/IFcmToken.java
similarity index 92%
rename from android/app/src/main/java/com/wix/reactnativenotifications/gcm/IFcmToken.java
rename to android/app/src/main/java/com/wix/reactnativenotifications/fcm/IFcmToken.java
index 9e75d39014c1a21bce7f854a3e0aa2d97abeaf0c..ce9fd72ed228f658b2a8ea2a41f64e16906767ab 100644
--- a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/IFcmToken.java
+++ b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/IFcmToken.java
@@ -1,4 +1,4 @@
-package com.wix.reactnativenotifications.gcm;
+package com.wix.reactnativenotifications.fcm;
public interface IFcmToken {
diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/fcm/INotificationsFcmApplication.java b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/INotificationsFcmApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..5a2cb1c5c7dd88dea61a2e8abf445191d7c2dafe
--- /dev/null
+++ b/android/app/src/main/java/com/wix/reactnativenotifications/fcm/INotificationsFcmApplication.java
@@ -0,0 +1,7 @@
+package com.wix.reactnativenotifications.fcm;
+
+import android.content.Context;
+
+public interface INotificationsFcmApplication {
+ IFcmToken getFcmToken(Context context);
+}
diff --git a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/INotificationsGcmApplication.java b/android/app/src/main/java/com/wix/reactnativenotifications/gcm/INotificationsGcmApplication.java
deleted file mode 100644
index d318ecc4a9e1b78c99ce43875459c5d841426ad5..0000000000000000000000000000000000000000
--- a/android/app/src/main/java/com/wix/reactnativenotifications/gcm/INotificationsGcmApplication.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.wix.reactnativenotifications.gcm;
-
-import android.content.Context;
-
-public interface INotificationsGcmApplication {
- IFcmToken getFcmToken(Context context);
-}
diff --git a/example/android/myapplication/src/main/AndroidManifest.xml b/example/android/myapplication/src/main/AndroidManifest.xml
index 5b14d1a61c145169b16b6d9521c08d63fe94547c..12292219a5ae5622c71b75e0060c1326a69d4c5f 100644
--- a/example/android/myapplication/src/main/AndroidManifest.xml
+++ b/example/android/myapplication/src/main/AndroidManifest.xml
@@ -12,9 +12,6 @@
android:usesCleartextTraffic="true"
android:label="@string/app_name"
android:theme="@style/AppTheme">
-