summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-firebase/src/android
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-09-26 01:35:13 +0200
committerJules Laplace <julescarbon@gmail.com>2017-09-26 01:35:13 +0200
commit597fa051833ca3df6eb185c0143ff82e02dacba1 (patch)
treecb25347477c57f82e955b054b70f4bb5359fb0d2 /StoneIsland/plugins/cordova-plugin-firebase/src/android
parent6a9186aea6b85beef28e3eb765fbf2322a1c7890 (diff)
push plugin ugh
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-firebase/src/android')
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePlugin.java601
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePluginInstanceIDService.java26
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePluginMessagingService.java127
-rw-r--r--StoneIsland/plugins/cordova-plugin-firebase/src/android/OnNotificationOpenReceiver.java24
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-firebase/src/android/build-extras.gradle1
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-firebase/src/android/build.gradle15
-rw-r--r--StoneIsland/plugins/cordova-plugin-firebase/src/android/colors.xml6
-rw-r--r--StoneIsland/plugins/cordova-plugin-firebase/src/android/google-services.json0
8 files changed, 0 insertions, 800 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePlugin.java b/StoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePlugin.java
deleted file mode 100755
index 7e4431df..00000000
--- a/StoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePlugin.java
+++ /dev/null
@@ -1,601 +0,0 @@
-package org.apache.cordova.firebase;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.support.v4.app.NotificationManagerCompat;
-import android.util.Base64;
-import android.util.Log;
-import com.google.android.gms.tasks.OnCompleteListener;
-import com.google.android.gms.tasks.OnFailureListener;
-import com.google.android.gms.tasks.Task;
-import com.google.firebase.analytics.FirebaseAnalytics;
-import com.google.firebase.iid.FirebaseInstanceId;
-import com.google.firebase.messaging.FirebaseMessaging;
-import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
-import com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo;
-import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
-import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue;
-import com.google.firebase.crash.FirebaseCrash;
-import me.leolin.shortcutbadger.ShortcutBadger;
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.PluginResult;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-public class FirebasePlugin extends CordovaPlugin {
-
- private FirebaseAnalytics mFirebaseAnalytics;
- private final String TAG = "FirebasePlugin";
- protected static final String KEY = "badge";
-
- private static boolean inBackground = true;
- private static ArrayList<Bundle> notificationStack = null;
- private static CallbackContext notificationCallbackContext;
- private static CallbackContext tokenRefreshCallbackContext;
-
- @Override
- protected void pluginInitialize() {
- final Context context = this.cordova.getActivity().getApplicationContext();
- final Bundle extras = this.cordova.getActivity().getIntent().getExtras();
- this.cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- Log.d(TAG, "Starting Firebase plugin");
- mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
- mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
- if (extras != null && extras.size() > 1) {
- if (FirebasePlugin.notificationStack == null) {
- FirebasePlugin.notificationStack = new ArrayList<Bundle>();
- }
- if (extras.containsKey("google.message_id")) {
- extras.putBoolean("tap", true);
- notificationStack.add(extras);
- }
- }
- }
- });
- }
-
- @Override
- public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
- if (action.equals("getInstanceId")) {
- this.getInstanceId(callbackContext);
- return true;
- } else if (action.equals("getToken")) {
- this.getToken(callbackContext);
- return true;
- } else if (action.equals("hasPermission")) {
- this.hasPermission(callbackContext);
- return true;
- } else if (action.equals("setBadgeNumber")) {
- this.setBadgeNumber(callbackContext, args.getInt(0));
- return true;
- } else if (action.equals("getBadgeNumber")) {
- this.getBadgeNumber(callbackContext);
- return true;
- } else if (action.equals("subscribe")) {
- this.subscribe(callbackContext, args.getString(0));
- return true;
- } else if (action.equals("unsubscribe")) {
- this.unsubscribe(callbackContext, args.getString(0));
- return true;
- } else if (action.equals("unregister")) {
- this.unregister(callbackContext);
- return true;
- } else if (action.equals("onNotificationOpen")) {
- this.onNotificationOpen(callbackContext);
- return true;
- } else if (action.equals("onTokenRefresh")) {
- this.onTokenRefresh(callbackContext);
- return true;
- } else if (action.equals("logEvent")) {
- this.logEvent(callbackContext, args.getString(0), args.getJSONObject(1));
- return true;
- } else if (action.equals("logError")) {
- this.logError(callbackContext, args.getString(0));
- return true;
- } else if (action.equals("setScreenName")) {
- this.setScreenName(callbackContext, args.getString(0));
- return true;
- } else if (action.equals("setUserId")) {
- this.setUserId(callbackContext, args.getString(0));
- return true;
- } else if (action.equals("setUserProperty")) {
- this.setUserProperty(callbackContext, args.getString(0), args.getString(1));
- return true;
- } else if (action.equals("activateFetched")) {
- this.activateFetched(callbackContext);
- return true;
- } else if (action.equals("fetch")) {
- if (args.length() > 0) this.fetch(callbackContext, args.getLong(0));
- else this.fetch(callbackContext);
- return true;
- } else if (action.equals("getByteArray")) {
- if (args.length() > 1) this.getByteArray(callbackContext, args.getString(0), args.getString(1));
- else this.getByteArray(callbackContext, args.getString(0), null);
- return true;
- } else if (action.equals("getValue")) {
- if (args.length() > 1) this.getValue(callbackContext, args.getString(0), args.getString(1));
- else this.getValue(callbackContext, args.getString(0), null);
- return true;
- } else if (action.equals("getInfo")) {
- this.getInfo(callbackContext);
- return true;
- } else if (action.equals("setConfigSettings")) {
- this.setConfigSettings(callbackContext, args.getJSONObject(0));
- return true;
- } else if (action.equals("setDefaults")) {
- if (args.length() > 1) this.setDefaults(callbackContext, args.getJSONObject(0), args.getString(1));
- else this.setDefaults(callbackContext, args.getJSONObject(0), null);
- return true;
- }
- return false;
- }
-
- @Override
- public void onPause(boolean multitasking) {
- FirebasePlugin.inBackground = true;
- }
-
- @Override
- public void onResume(boolean multitasking) {
- FirebasePlugin.inBackground = false;
- }
-
- @Override
- public void onReset() {
- FirebasePlugin.notificationCallbackContext = null;
- FirebasePlugin.tokenRefreshCallbackContext = null;
- }
-
- private void onNotificationOpen(final CallbackContext callbackContext) {
- FirebasePlugin.notificationCallbackContext = callbackContext;
- if (FirebasePlugin.notificationStack != null) {
- for (Bundle bundle : FirebasePlugin.notificationStack) {
- FirebasePlugin.sendNotification(bundle);
- }
- FirebasePlugin.notificationStack.clear();
- }
- }
-
- private void onTokenRefresh(final CallbackContext callbackContext) {
- FirebasePlugin.tokenRefreshCallbackContext = callbackContext;
-
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- String currentToken = FirebaseInstanceId.getInstance().getToken();
-
- if (currentToken != null) {
- FirebasePlugin.sendToken(currentToken);
- }
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- public static void sendNotification(Bundle bundle) {
- if (!FirebasePlugin.hasNotificationsCallback()) {
- if (FirebasePlugin.notificationStack == null) {
- FirebasePlugin.notificationStack = new ArrayList<Bundle>();
- }
- notificationStack.add(bundle);
- return;
- }
- final CallbackContext callbackContext = FirebasePlugin.notificationCallbackContext;
- if (callbackContext != null && bundle != null) {
- JSONObject json = new JSONObject();
- Set<String> keys = bundle.keySet();
- for (String key : keys) {
- try {
- json.put(key, bundle.get(key));
- } catch (JSONException e) {
- callbackContext.error(e.getMessage());
- return;
- }
- }
-
- PluginResult pluginresult = new PluginResult(PluginResult.Status.OK, json);
- pluginresult.setKeepCallback(true);
- callbackContext.sendPluginResult(pluginresult);
- }
- }
-
- public static void sendToken(String token) {
- if (FirebasePlugin.tokenRefreshCallbackContext == null) {
- return;
- }
- final CallbackContext callbackContext = FirebasePlugin.tokenRefreshCallbackContext;
- if (callbackContext != null && token != null) {
- PluginResult pluginresult = new PluginResult(PluginResult.Status.OK, token);
- pluginresult.setKeepCallback(true);
- callbackContext.sendPluginResult(pluginresult);
- }
- }
-
- public static boolean inBackground() {
- return FirebasePlugin.inBackground;
- }
-
- public static boolean hasNotificationsCallback() {
- return FirebasePlugin.notificationCallbackContext != null;
- }
-
- @Override
- public void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
- final Bundle data = intent.getExtras();
- if (data != null && data.containsKey("google.message_id")) {
- data.putBoolean("tap", true);
- FirebasePlugin.sendNotification(data);
- }
- }
-
- // DEPRECTED - alias of getToken
- private void getInstanceId(final CallbackContext callbackContext) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- String token = FirebaseInstanceId.getInstance().getToken();
- callbackContext.success(token);
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void getToken(final CallbackContext callbackContext) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- String token = FirebaseInstanceId.getInstance().getToken();
- callbackContext.success(token);
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void hasPermission(final CallbackContext callbackContext) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- Context context = cordova.getActivity();
- NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
- boolean areNotificationsEnabled = notificationManagerCompat.areNotificationsEnabled();
- JSONObject object = new JSONObject();
- object.put("isEnabled", areNotificationsEnabled);
- callbackContext.success(object);
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void setBadgeNumber(final CallbackContext callbackContext, final int number) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- Context context = cordova.getActivity();
- SharedPreferences.Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
- editor.putInt(KEY, number);
- editor.apply();
- ShortcutBadger.applyCount(context, number);
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void getBadgeNumber(final CallbackContext callbackContext) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- Context context = cordova.getActivity();
- SharedPreferences settings = context.getSharedPreferences(KEY, Context.MODE_PRIVATE);
- int number = settings.getInt(KEY, 0);
- callbackContext.success(number);
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void subscribe(final CallbackContext callbackContext, final String topic) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- FirebaseMessaging.getInstance().subscribeToTopic(topic);
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void unsubscribe(final CallbackContext callbackContext, final String topic) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void unregister(final CallbackContext callbackContext) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- FirebaseInstanceId.getInstance().deleteInstanceId();
- String currentToken = FirebaseInstanceId.getInstance().getToken();
- if (currentToken != null) {
- FirebasePlugin.sendToken(currentToken);
- }
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void logEvent(final CallbackContext callbackContext, final String name, final JSONObject params) throws JSONException {
- final Bundle bundle = new Bundle();
- Iterator iter = params.keys();
- while (iter.hasNext()) {
- String key = (String) iter.next();
- Object value = params.get(key);
-
- if (value instanceof Integer || value instanceof Double) {
- bundle.putFloat(key, ((Number) value).floatValue());
- } else {
- bundle.putString(key, value.toString());
- }
- }
-
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- mFirebaseAnalytics.logEvent(name, bundle);
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void logError(final CallbackContext callbackContext, final String message) throws JSONException {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- FirebaseCrash.report(new Exception(message));
- callbackContext.success(1);
- } catch (Exception e) {
- FirebaseCrash.log(e.getMessage());
- e.printStackTrace();
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void setScreenName(final CallbackContext callbackContext, final String name) {
- // This must be called on the main thread
- cordova.getActivity().runOnUiThread(new Runnable() {
- public void run() {
- try {
- mFirebaseAnalytics.setCurrentScreen(cordova.getActivity(), name, null);
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void setUserId(final CallbackContext callbackContext, final String id) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- mFirebaseAnalytics.setUserId(id);
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void setUserProperty(final CallbackContext callbackContext, final String name, final String value) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- mFirebaseAnalytics.setUserProperty(name, value);
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void activateFetched(final CallbackContext callbackContext) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- final boolean activated = FirebaseRemoteConfig.getInstance().activateFetched();
- callbackContext.success(String.valueOf(activated));
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void fetch(CallbackContext callbackContext) {
- fetch(callbackContext, FirebaseRemoteConfig.getInstance().fetch());
- }
-
- private void fetch(CallbackContext callbackContext, long cacheExpirationSeconds) {
- fetch(callbackContext, FirebaseRemoteConfig.getInstance().fetch(cacheExpirationSeconds));
- }
-
- private void fetch(final CallbackContext callbackContext, final Task<Void> task) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- task.addOnCompleteListener(new OnCompleteListener<Void>() {
- @Override
- public void onComplete(Task<Void> task) {
- callbackContext.success();
- }
- }).addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(Exception e) {
- callbackContext.error(e.getMessage());
- }
- });
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void getByteArray(final CallbackContext callbackContext, final String key, final String namespace) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- byte[] bytes = namespace == null ? FirebaseRemoteConfig.getInstance().getByteArray(key)
- : FirebaseRemoteConfig.getInstance().getByteArray(key, namespace);
- JSONObject object = new JSONObject();
- object.put("base64", Base64.encodeToString(bytes, Base64.DEFAULT));
- object.put("array", new JSONArray(bytes));
- callbackContext.success(object);
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void getValue(final CallbackContext callbackContext, final String key, final String namespace) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- FirebaseRemoteConfigValue value = namespace == null ? FirebaseRemoteConfig.getInstance().getValue(key)
- : FirebaseRemoteConfig.getInstance().getValue(key, namespace);
- callbackContext.success(value.asString());
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void getInfo(final CallbackContext callbackContext) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- FirebaseRemoteConfigInfo remoteConfigInfo = FirebaseRemoteConfig.getInstance().getInfo();
- JSONObject info = new JSONObject();
-
- JSONObject settings = new JSONObject();
- settings.put("developerModeEnabled", remoteConfigInfo.getConfigSettings().isDeveloperModeEnabled());
- info.put("configSettings", settings);
-
- info.put("fetchTimeMillis", remoteConfigInfo.getFetchTimeMillis());
- info.put("lastFetchStatus", remoteConfigInfo.getLastFetchStatus());
-
- callbackContext.success(info);
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void setConfigSettings(final CallbackContext callbackContext, final JSONObject config) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- boolean devMode = config.getBoolean("developerModeEnabled");
- FirebaseRemoteConfigSettings.Builder settings = new FirebaseRemoteConfigSettings.Builder()
- .setDeveloperModeEnabled(devMode);
- FirebaseRemoteConfig.getInstance().setConfigSettings(settings.build());
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private void setDefaults(final CallbackContext callbackContext, final JSONObject defaults, final String namespace) {
- cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- try {
- if (namespace == null)
- FirebaseRemoteConfig.getInstance().setDefaults(defaultsToMap(defaults));
- else
- FirebaseRemoteConfig.getInstance().setDefaults(defaultsToMap(defaults), namespace);
- callbackContext.success();
- } catch (Exception e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- private static Map<String, Object> defaultsToMap(JSONObject object) throws JSONException {
- final Map<String, Object> map = new HashMap<String, Object>();
-
- for (Iterator<String> keys = object.keys(); keys.hasNext(); ) {
- String key = keys.next();
- Object value = object.get(key);
-
- if (value instanceof Integer) {
- //setDefaults() should take Longs
- value = new Long((Integer) value);
- } else if (value instanceof JSONArray) {
- JSONArray array = (JSONArray) value;
- if (array.length() == 1 && array.get(0) instanceof String) {
- //parse byte[] as Base64 String
- value = Base64.decode(array.getString(0), Base64.DEFAULT);
- } else {
- //parse byte[] as numeric array
- byte[] bytes = new byte[array.length()];
- for (int i = 0; i < array.length(); i++)
- bytes[i] = (byte) array.getInt(i);
- value = bytes;
- }
- }
-
- map.put(key, value);
- }
- return map;
- }
-}
diff --git a/StoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePluginInstanceIDService.java b/StoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePluginInstanceIDService.java
deleted file mode 100755
index 96140f02..00000000
--- a/StoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePluginInstanceIDService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.apache.cordova.firebase;
-
-import android.util.Log;
-
-import com.google.firebase.iid.FirebaseInstanceId;
-import com.google.firebase.iid.FirebaseInstanceIdService;
-
-
-public class FirebasePluginInstanceIDService extends FirebaseInstanceIdService {
-
- private static final String TAG = "FirebasePlugin";
-
- /**
- * Called if InstanceID token is updated. This may occur if the security of
- * the previous token had been compromised. Note that this is called when the InstanceID token
- * is initially generated so this is where you would retrieve the token.
- */
- @Override
- public void onTokenRefresh() {
- // Get updated InstanceID token.
- String refreshedToken = FirebaseInstanceId.getInstance().getToken();
- Log.d(TAG, "Refreshed token: " + refreshedToken);
-
- FirebasePlugin.sendToken(refreshedToken);
- }
-}
diff --git a/StoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePluginMessagingService.java b/StoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePluginMessagingService.java
deleted file mode 100755
index a42ce60e..00000000
--- a/StoneIsland/plugins/cordova-plugin-firebase/src/android/FirebasePluginMessagingService.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package org.apache.cordova.firebase;
-
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.media.RingtoneManager;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.v4.app.NotificationCompat;
-import android.util.Log;
-import android.app.Notification;
-import android.text.TextUtils;
-
-import com.google.firebase.messaging.FirebaseMessagingService;
-import com.google.firebase.messaging.RemoteMessage;
-
-import java.util.Map;
-import java.util.Random;
-
-public class FirebasePluginMessagingService extends FirebaseMessagingService {
-
- private static final String TAG = "FirebasePlugin";
-
- /**
- * Called when message is received.
- *
- * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
- */
- @Override
- public void onMessageReceived(RemoteMessage remoteMessage) {
- // [START_EXCLUDE]
- // There are two types of messages data messages and notification messages. Data messages are handled
- // here in onMessageReceived whether the app is in the foreground or background. Data messages are the type
- // traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app
- // is in the foreground. When the app is in the background an automatically generated notification is displayed.
- // When the user taps on the notification they are returned to the app. Messages containing both notification
- // and data payloads are treated as notification messages. The Firebase console always sends notification
- // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
- // [END_EXCLUDE]
-
- // TODO(developer): Handle FCM messages here.
- // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
- String title;
- String text;
- String id;
- if (remoteMessage.getNotification() != null) {
- title = remoteMessage.getNotification().getTitle();
- text = remoteMessage.getNotification().getBody();
- id = remoteMessage.getMessageId();
- } else {
- title = remoteMessage.getData().get("title");
- text = remoteMessage.getData().get("text");
- id = remoteMessage.getData().get("id");
- }
-
- if(TextUtils.isEmpty(id)){
- Random rand = new Random();
- int n = rand.nextInt(50) + 1;
- id = Integer.toString(n);
- }
-
- Log.d(TAG, "From: " + remoteMessage.getFrom());
- Log.d(TAG, "Notification Message id: " + id);
- Log.d(TAG, "Notification Message Title: " + title);
- Log.d(TAG, "Notification Message Body/Text: " + text);
-
- // TODO: Add option to developer to configure if show notification when app on foreground
- if (!TextUtils.isEmpty(text) || !TextUtils.isEmpty(title) || (!remoteMessage.getData().isEmpty())) {
- boolean showNotification = (FirebasePlugin.inBackground() || !FirebasePlugin.hasNotificationsCallback()) && (!TextUtils.isEmpty(text) || !TextUtils.isEmpty(title));
- sendNotification(id, title, text, remoteMessage.getData(), showNotification);
- }
- }
-
- private void sendNotification(String id, String title, String messageBody, Map<String, String> data, boolean showNotification) {
- Bundle bundle = new Bundle();
- for (String key : data.keySet()) {
- bundle.putString(key, data.get(key));
- }
- if (showNotification) {
- Intent intent = new Intent(this, OnNotificationOpenReceiver.class);
- intent.putExtras(bundle);
- PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id.hashCode(), intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
-
- Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
- NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
- .setContentTitle(title)
- .setContentText(messageBody)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
- .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
- .setAutoCancel(true)
- .setSound(defaultSoundUri)
- .setContentIntent(pendingIntent);
-
- int resID = getResources().getIdentifier("notification_icon", "drawable", getPackageName());
- if (resID != 0) {
- notificationBuilder.setSmallIcon(resID);
- } else {
- notificationBuilder.setSmallIcon(getApplicationInfo().icon);
- }
-
- if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M)
- {
- int accentID = getResources().getIdentifier("accent", "color", getPackageName());
- notificationBuilder.setColor(getResources().getColor(accentID, null));
- }
-
- Notification notification = notificationBuilder.build();
- if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP){
- int iconID = android.R.id.icon;
- int notiID = getResources().getIdentifier("notification_big", "drawable", getPackageName());
- if (notification.contentView != null) {
- notification.contentView.setImageViewResource(iconID, notiID);
- }
- }
- NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-
- notificationManager.notify(id.hashCode(), notification);
- } else {
- bundle.putBoolean("tap", false);
- bundle.putString("title", title);
- bundle.putString("body", messageBody);
- FirebasePlugin.sendNotification(bundle);
- }
- }
-}
diff --git a/StoneIsland/plugins/cordova-plugin-firebase/src/android/OnNotificationOpenReceiver.java b/StoneIsland/plugins/cordova-plugin-firebase/src/android/OnNotificationOpenReceiver.java
deleted file mode 100644
index a7f63757..00000000
--- a/StoneIsland/plugins/cordova-plugin-firebase/src/android/OnNotificationOpenReceiver.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.apache.cordova.firebase;
-
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-
-public class OnNotificationOpenReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- PackageManager pm = context.getPackageManager();
- Intent launchIntent = pm.getLaunchIntentForPackage(context.getPackageName());
-
- launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
- Bundle data = intent.getExtras();
- data.putBoolean("tap", true);
- FirebasePlugin.sendNotification(data);
- launchIntent.putExtras(data);
- context.startActivity(launchIntent);
- }
-}
diff --git a/StoneIsland/plugins/cordova-plugin-firebase/src/android/build-extras.gradle b/StoneIsland/plugins/cordova-plugin-firebase/src/android/build-extras.gradle
deleted file mode 100755
index 67b387f5..00000000
--- a/StoneIsland/plugins/cordova-plugin-firebase/src/android/build-extras.gradle
+++ /dev/null
@@ -1 +0,0 @@
-apply plugin: 'com.google.gms.google-services' \ No newline at end of file
diff --git a/StoneIsland/plugins/cordova-plugin-firebase/src/android/build.gradle b/StoneIsland/plugins/cordova-plugin-firebase/src/android/build.gradle
deleted file mode 100755
index d5cb4edd..00000000
--- a/StoneIsland/plugins/cordova-plugin-firebase/src/android/build.gradle
+++ /dev/null
@@ -1,15 +0,0 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.google.gms:google-services:3.0.0'
- }
-}
-repositories {
- mavenCentral()
-}
-dependencies {
- compile 'me.leolin:ShortcutBadger:1.1.4@aar'
- compile 'com.google.firebase:firebase-crash:+'
-}
diff --git a/StoneIsland/plugins/cordova-plugin-firebase/src/android/colors.xml b/StoneIsland/plugins/cordova-plugin-firebase/src/android/colors.xml
deleted file mode 100644
index 6f1665a5..00000000
--- a/StoneIsland/plugins/cordova-plugin-firebase/src/android/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <color name="primary">#FFFFFF00</color>
- <color name="primary_dark">#FF220022</color>
- <color name="accent">#FF00FFFF</color>
-</resources> \ No newline at end of file
diff --git a/StoneIsland/plugins/cordova-plugin-firebase/src/android/google-services.json b/StoneIsland/plugins/cordova-plugin-firebase/src/android/google-services.json
deleted file mode 100644
index e69de29b..00000000
--- a/StoneIsland/plugins/cordova-plugin-firebase/src/android/google-services.json
+++ /dev/null