Commit e434c620 authored by Yogev Ben David's avatar Yogev Ben David Committed by GitHub

Remove GCM leftovers (#359)

* Remove GCM leftovers, fix typos

* Print android unit tests output
parent b4030449
......@@ -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 {
......
......@@ -4,7 +4,7 @@
package="com.wix.reactnativenotifications">
<!--
Permissions required for enabling GCM.
Permissions required for enabling FCM.
-->
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
......@@ -22,7 +22,7 @@
<service android:name=".core.ProxyService"/>
<service
android:name=".gcm.FcmInstanceIdListenerService">
android:name=".fcm.FcmInstanceIdListenerService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
......@@ -30,7 +30,7 @@
</service>
<service
android:name=".gcm.FcmInstanceIdRefreshHandlerService"
android:name=".fcm.FcmInstanceIdRefreshHandlerService"
android:exported="false" />
</application>
......
......@@ -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";
......
......@@ -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);
......
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);
}
}
}
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();
}
}
}
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);
}
......
package com.wix.reactnativenotifications.gcm;
package com.wix.reactnativenotifications.fcm;
public interface IFcmToken {
......
package com.wix.reactnativenotifications.gcm;
package com.wix.reactnativenotifications.fcm;
import android.content.Context;
public interface INotificationsGcmApplication {
public interface INotificationsFcmApplication {
IFcmToken getFcmToken(Context context);
}
......@@ -12,9 +12,6 @@
android:usesCleartextTraffic="true"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<meta-data
android:name="com.wix.reactnativenotifications.gcmSenderId"
android:value="434691868895\0"/>
<activity
android:name=".MainActivity"
......
#!/usr/bin/python
from urllib2 import *
import json
import sys
if len(sys.argv) < 2:
print 'Error: missing token argument'
sys.exit(1)
API_KEY = 'AIzaSyBVtqdO_SgPVhhXnyNGC_VXSbIX-fxk1YY'
TOKEN = sys.argv[1]
data = {
"to": TOKEN,
"data" : {
"body": "SUCCESS! Sent from script :)",
"title": "Wix Example Project"
}
}
dataJson = json.dumps(data)
request = Request(
'https://gcm-http.googleapis.com/gcm/send',
dataJson,
{
"Authorization" : "key="+API_KEY,
"Content-type" : "application/json"
}
)
print "Sending notification..."
print urlopen(request).read()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment