Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #374 issue: colors.xml resource already exists on android insta… #938

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,6 @@ window.FirebasePlugin.getValue("key", function(value) {
}, function(error) {
console.error(error);
});
// or, specify a namespace for the config value
window.FirebasePlugin.getValue("key", "namespace", function(value) {
console.log(value);
}, function(error) {
console.error(error);
});
```

## getByteArray (Android only)
Expand All @@ -272,15 +266,6 @@ window.FirebasePlugin.getByteArray("key", function(bytes) {
}, function(error) {
console.error(error);
});
// or, specify a namespace for the byte array
window.FirebasePlugin.getByteArray("key", "namespace", function(bytes) {
// a Base64 encoded string that represents the value for "key"
console.log(bytes.base64);
// a numeric array containing the values of the byte array (i.e. [0xFF, 0x00])
console.log(bytes.array);
}, function(error) {
console.error(error);
});
```

## getInfo (Android only)
Expand Down Expand Up @@ -332,8 +317,6 @@ var defaults = {
}
// set defaults
window.FirebasePlugin.setDefaults(defaults);
// or, specify a namespace
window.FirebasePlugin.setDefaults(defaults, "namespace");
```

## startTrace
Expand Down
3 changes: 1 addition & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ xmlns:android="http://schemas.android.com/apk/res/android">
<resource-file src="src/android/cordova-plugin-firebase-strings.xml" target="res/values/cordova-plugin-firebase-strings.xml" />
<source-file src="src/android/FirebasePlugin.java" target-dir="src/org/apache/cordova/firebase" />
<source-file src="src/android/OnNotificationOpenReceiver.java" target-dir="src/org/apache/cordova/firebase" />
<source-file src="src/android/FirebasePluginInstanceIDService.java" target-dir="src/org/apache/cordova/firebase" />
<source-file src="src/android/FirebasePluginMessagingService.java" target-dir="src/org/apache/cordova/firebase" />
<source-file src="src/android/FirebasePluginMessageReceiver.java" target-dir="src/org/apache/cordova/firebase" />
<source-file src="src/android/FirebasePluginMessageReceiverManager.java" target-dir="src/org/apache/cordova/firebase" />
<source-file src="src/android/colors.xml" target-dir="res/values" />
<source-file src="src/android/cv_plugin_fb_colors.xml" target-dir="res/values" />

<framework src="src/android/build.gradle" custom="true" type="gradleReference" />
<framework src="com.google.android.gms:play-services-tagmanager:+" />
Expand Down
36 changes: 9 additions & 27 deletions src/android/FirebasePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,10 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
}
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);
}
this.getByteArray(callbackContext, args.getString(0));
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);
}
this.getValue(callbackContext, args.getString(0));
return true;
} else if (action.equals("getInfo")) {
this.getInfo(callbackContext);
Expand All @@ -174,11 +166,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
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);
}
this.setDefaults(callbackContext, args.getJSONObject(0));
return true;
} else if (action.equals("verifyPhoneNumber")) {
this.verifyPhoneNumber(callbackContext, args.getString(0), args.getInt(1));
Expand Down Expand Up @@ -602,12 +590,11 @@ public void onFailure(Exception e) {
});
}

private void getByteArray(final CallbackContext callbackContext, final String key, final String namespace) {
private void getByteArray(final CallbackContext callbackContext, final String key) {
cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
byte[] bytes = namespace == null ? FirebaseRemoteConfig.getInstance().getByteArray(key)
: FirebaseRemoteConfig.getInstance().getByteArray(key, namespace);
byte[] bytes = FirebaseRemoteConfig.getInstance().getByteArray(key);
JSONObject object = new JSONObject();
object.put("base64", Base64.encodeToString(bytes, Base64.DEFAULT));
object.put("array", new JSONArray(bytes));
Expand All @@ -620,13 +607,11 @@ public void run() {
});
}

private void getValue(final CallbackContext callbackContext, final String key, final String namespace) {
private void getValue(final CallbackContext callbackContext, final String key) {
cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
FirebaseRemoteConfigValue value = namespace == null
? FirebaseRemoteConfig.getInstance().getValue(key)
: FirebaseRemoteConfig.getInstance().getValue(key, namespace);
FirebaseRemoteConfigValue value = FirebaseRemoteConfig.getInstance().getValue(key);
callbackContext.success(value.asString());
} catch (Exception e) {
Crashlytics.logException(e);
Expand Down Expand Up @@ -676,14 +661,11 @@ public void run() {
});
}

private void setDefaults(final CallbackContext callbackContext, final JSONObject defaults, final String namespace) {
private void setDefaults(final CallbackContext callbackContext, final JSONObject defaults) {
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) {
Crashlytics.logException(e);
Expand Down Expand Up @@ -882,7 +864,7 @@ public void run() {
}

if (myTrace != null && myTrace instanceof Trace) {
myTrace.incrementCounter(counterNamed);
myTrace.incrementMetric(counterNamed, 1);
callbackContext.success();
} else {
callbackContext.error("Trace not found");
Expand Down
25 changes: 0 additions & 25 deletions src/android/FirebasePluginInstanceIDService.java

This file was deleted.

15 changes: 15 additions & 0 deletions src/android/FirebasePluginMessagingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ private String getStringResource(String name) {
);
}


/**
* 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 onNewToken(String refreshedToken) {
super.onNewToken(refreshedToken);
Log.e("NEW_TOKEN",refreshedToken);
Log.d(TAG, "Refreshed token: " + refreshedToken);
FirebasePlugin.sendToken(refreshedToken);
}


/**
* Called when message is received.
*
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions www/firebase-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ exports.fetch = function (cacheExpirationSeconds, success, error) {
}
};

exports.getByteArray = function (key, namespace, success, error) {
exports.getByteArray = function (key, success, error) {
if (typeof success === 'function') {
success();
}
};

exports.getValue = function (key, namespace, success, error) {
exports.getValue = function (key, success, error) {
if (typeof success === 'function') {
success();
}
Expand All @@ -128,7 +128,7 @@ exports.setConfigSettings = function (settings, success, error) {
}
};

exports.setDefaults = function (defaults, namespace, success, error) {
exports.setDefaults = function (defaults, success, error) {
if (typeof success === 'function') {
success();
}
Expand Down
33 changes: 6 additions & 27 deletions www/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,12 @@ exports.fetch = function (cacheExpirationSeconds, success, error) {
exec(success, error, "FirebasePlugin", "fetch", args);
};

exports.getByteArray = function (key, namespace, success, error) {
var args = [key];
if (typeof namespace === 'string') {
args.push(namespace);
} else {
error = success;
success = namespace;
}
exec(success, error, "FirebasePlugin", "getByteArray", args);
exports.getByteArray = function (key, success, error) {
exec(success, error, "FirebasePlugin", "getByteArray", [key]);
};

exports.getValue = function (key, namespace, success, error) {
var args = [key];
if (typeof namespace === 'string') {
args.push(namespace);
} else {
error = success;
success = namespace;
}
exec(success, error, "FirebasePlugin", "getValue", args);
exports.getValue = function (key, success, error) {
exec(success, error, "FirebasePlugin", "getValue", [key]);
};

exports.getInfo = function (success, error) {
Expand All @@ -121,15 +107,8 @@ exports.setConfigSettings = function (settings, success, error) {
exec(success, error, "FirebasePlugin", "setConfigSettings", [settings]);
};

exports.setDefaults = function (defaults, namespace, success, error) {
var args = [defaults];
if (typeof namespace === 'string') {
args.push(namespace);
} else {
error = success;
success = namespace;
}
exec(success, error, "FirebasePlugin", "setDefaults", args);
exports.setDefaults = function (defaults, success, error) {
exec(success, error, "FirebasePlugin", "setDefaults", [defaults]);
};

exports.startTrace = function (name, success, error) {
Expand Down