Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ff259c9
Updated name of Firestore pod.
Apr 26, 2018
0d3f1e1
Fixed new pod command correctly.
May 4, 2018
42fb138
Changed name and url to point to @engagemobile
wrasmuss-eng May 10, 2018
7dc1c10
Changed name and url to point to @engagemobile
wrasmuss-eng May 10, 2018
f4871f2
Changed name and url to point to @engagemobile
wrasmuss-eng May 10, 2018
15946aa
Changed header references
wrasmuss-eng May 22, 2018
07d9fa3
Changed change firestore version reference
wrasmuss-eng May 22, 2018
492d6e3
Remove qualifiers from firebase name
wrasmuss-eng May 22, 2018
54bd56b
[BV-196] Implement code for supporting change configure firebase
tvanh09 Jun 8, 2018
bfdab6a
[BV-196] Import class FirebaseApp and FirebaeOptions
tvanh09 Jun 11, 2018
579a7a8
[BV-196] Changed change firestore version reference
tvanh09 Jun 11, 2018
506940c
Merge pull request #1 from EngageMobile/BV-196
wrasmuss-eng Jun 11, 2018
6ddd260
[BV-260] Implement Firebase Analytics logEvent() method
tvanh09 Jun 20, 2018
aced88f
[BV-260] Changed change firestore version reference
tvanh09 Jun 20, 2018
1f86cfd
Merge pull request #2 from EngageMobile/BV-260
Jun 20, 2018
6654f0d
[BV-495] Implement ability get, update, delete, set document of subco…
tvanh09 Aug 2, 2018
32fad66
[BV-495] Implement ability get, update, delete, set document of subco…
tvanh09 Aug 3, 2018
a727383
[BV-495] Changed change firestore version reference
tvanh09 Aug 3, 2018
9ef2153
[BV-495] Update source file for Android
tvanh09 Aug 6, 2018
3a55f3c
[BV-495] Changed change firestore version reference
tvanh09 Aug 6, 2018
cc4c8f5
Merge pull request #3 from EngageMobile/BV-495
Aug 6, 2018
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.git.safe
/node_modules
.DS_Store
*.iml
.idea
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "cordova-plugin-firestore",
"version": "1.1.0",
"name": "engage-cordova-plugin-firestore",
"version": "1.1.14",
"cordova": {
"id": "cordova-plugin-firestore",
"id": "engage-cordova-plugin-firestore",
"platforms": [
"android",
"ios",
Expand All @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/ReallySmallSoftware/cordova-plugin-firestore.git"
"url": "https://github.com/EngageMobile/cordova-plugin-firestore.git"
},
"author": "Richard Windley <richard.windley@gmail.com> (http://www.reallysmall.co.uk)",
"license": "Apache-2.0",
Expand Down
13 changes: 11 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-firestore" version="1.1.0">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="engage-cordova-plugin-firestore" version="1.1.14">
<name>Cordova Firestore Plugin</name>
<description>Google Firebase Firestore</description>
<license>MIT</license>
Expand Down Expand Up @@ -30,7 +30,9 @@
</feature>
</config-file>

<preference name="FIREBASE_CORE_VERSION" default="11.8.0"/>
<preference name="ANDROID_FIREBASE_VERSION" default="11.8.0"/>
<framework src="com.google.firebase:firebase-core:$FIREBASE_CORE_VERSION" />
<framework src="com.google.firebase:firebase-firestore:$ANDROID_FIREBASE_VERSION"/>
<framework src="com.google.code.gson:gson:2.8.2"/>
<framework src="org.json:json:20171018"/>
Expand Down Expand Up @@ -72,6 +74,12 @@
<source-file src="src/android/uk/co/reallysmall/cordova/plugin/firestore/DocSetOptions.java" target-dir="src/uk/co/reallysmall/cordova/plugin/firestore"/>
<source-file src="src/android/uk/co/reallysmall/cordova/plugin/firestore/TransactionDetails.java" target-dir="src/uk/co/reallysmall/cordova/plugin/firestore"/>
<source-file src="src/android/uk/co/reallysmall/cordova/plugin/firestore/TransactionOperationType.java" target-dir="src/uk/co/reallysmall/cordova/plugin/firestore"/>
<source-file src="src/android/uk/co/reallysmall/cordova/plugin/firestore/LogEventHandler.java" target-dir="src/uk/co/reallysmall/cordova/plugin/firestore"/>
<source-file src="src/android/uk/co/reallysmall/cordova/plugin/firestore/DocOfSubCollectionSetHandler.java" target-dir="src/uk/co/reallysmall/cordova/plugin/firestore"/>
<source-file src="src/android/uk/co/reallysmall/cordova/plugin/firestore/DocOfSubCollectionGetHandler.java" target-dir="src/uk/co/reallysmall/cordova/plugin/firestore"/>
<source-file src="src/android/uk/co/reallysmall/cordova/plugin/firestore/DocOfSubCollectionDeleteHandler.java" target-dir="src/uk/co/reallysmall/cordova/plugin/firestore"/>
<source-file src="src/android/uk/co/reallysmall/cordova/plugin/firestore/DocOfSubCollectionUpdateHandler.java" target-dir="src/uk/co/reallysmall/cordova/plugin/firestore"/>
<source-file src="src/android/uk/co/reallysmall/cordova/plugin/firestore/SubCollectionGetHandler.java" target-dir="src/uk/co/reallysmall/cordova/plugin/firestore"/>
</platform>

<platform name="ios">
Expand All @@ -84,7 +92,8 @@
</feature>
</config-file>

<framework src="FirebaseFirestore" type="podspec" spec="~> 0.10.2"/>
<framework src="Firebase/Core" type="podspec" spec=""/>
<framework src="FirebaseFirestore" type="podspec" spec="0.11.0"/>

<header-file src="src/ios/FirestorePlugin.h"/>
<source-file src="src/ios/FirestorePlugin.m"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package uk.co.reallysmall.cordova.plugin.firestore;


import android.support.annotation.NonNull;
import android.util.Log;

import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.firestore.DocumentReference;

import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;

public class DocOfSubCollectionDeleteHandler implements ActionHandler {

private FirestorePlugin firestorePlugin;

public DocOfSubCollectionDeleteHandler(FirestorePlugin firestorePlugin) {
this.firestorePlugin = firestorePlugin;
}

@Override
public boolean handle(JSONArray args, final CallbackContext callbackContext) {
try {
final String collectionPath = args.getString(0);
final String doc = args.getString(1);
final String subCollection = args.getString(2);
final String docOfSubCollectionId = args.getString(3);

Log.d(FirestorePlugin.TAG, "Deleting document of sub collection");

try {
DocumentReference documentRef = firestorePlugin.getDatabase().collection(collectionPath).document(doc).collection(subCollection).document(docOfSubCollectionId);
Log.d(FirestorePlugin.TAG, "Get for document of sub collection" + collectionPath + "/" + doc);

documentRef.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
callbackContext.success(0);
Log.d(FirestorePlugin.TAG, "Successfully deleted document of sub collection");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(FirestorePlugin.TAG, "Error deleting document of sub collection", e);
callbackContext.error(e.getMessage());
}
});
} catch (Exception e) {
Log.e(FirestorePlugin.TAG, "Error processing document of sub collection delete in thread", e);
callbackContext.error(e.getMessage());
}

} catch (JSONException e) {
Log.e(FirestorePlugin.TAG, "Error processing document of sub collection delete", e);
callbackContext.error(e.getMessage());
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package uk.co.reallysmall.cordova.plugin.firestore;


import android.support.annotation.NonNull;
import android.util.Log;

import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot;

import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;

import static uk.co.reallysmall.cordova.plugin.firestore.PluginResultHelper.createPluginResult;

public class DocOfSubCollectionGetHandler implements ActionHandler {

private FirestorePlugin firestorePlugin;

public DocOfSubCollectionGetHandler(FirestorePlugin firestorePlugin) {
this.firestorePlugin = firestorePlugin;
}

@Override
public boolean handle(JSONArray args, final CallbackContext callbackContext) {
try {
final String collectionPath = args.getString(0);
final String docId = args.getString(1);
final String subCollection = args.getString(2);
final String docOfSubCollectionId = args.getString(3);

Log.d(FirestorePlugin.TAG, "Listening to document of sub collection");

try {
DocumentReference documentRef = firestorePlugin.getDatabase().collection(collectionPath).document(docId).collection(subCollection).document(docOfSubCollectionId);

documentRef.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
callbackContext.sendPluginResult(createPluginResult(documentSnapshot, false));
Log.d(FirestorePlugin.TAG, "Successfully got document of sub collection");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(FirestorePlugin.TAG, "Error getting document of sub collection", e);
callbackContext.error(e.getMessage());
}
});
} catch (Exception e) {
Log.e(FirestorePlugin.TAG, "Error processing document of sub collection get in thread", e);
callbackContext.error(e.getMessage());
}

} catch (JSONException e) {
Log.e(FirestorePlugin.TAG, "Error processing document of sub collection snapshot", e);
callbackContext.error(e.getMessage());
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package uk.co.reallysmall.cordova.plugin.firestore;

import android.support.annotation.NonNull;
import android.util.Log;

import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.SetOptions;

import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class DocOfSubCollectionSetHandler implements ActionHandler {

private FirestorePlugin firestorePlugin;

public DocOfSubCollectionSetHandler(FirestorePlugin firestorePlugin) {
this.firestorePlugin = firestorePlugin;
}

@Override
public boolean handle(JSONArray args, final CallbackContext callbackContext) {
try {
final String collection = args.getString(0);
final String docId = args.getString(1);
final String subCollection = args.getString(2);
final String docOfSubCollectionId = args.getString(3);
final JSONObject data = args.getJSONObject(4);

final JSONObject options;

if (!args.isNull(5)) {
options = args.getJSONObject(5);
} else {
options = null;
}

try {

SetOptions setOptions = DocSetOptions.getSetOptions(options);

Log.d(FirestorePlugin.TAG, "Setting document of sub collection");

DocumentReference documentReference = firestorePlugin.getDatabase().collection(collection).document(docId).collection(subCollection).document(docOfSubCollectionId);

OnSuccessListener onSuccessListener = new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
callbackContext.success();
Log.d(FirestorePlugin.TAG, "Successfully written document of sub collection");
}
};

OnFailureListener onFailureListener = new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(FirestorePlugin.TAG, "Error writing document of sub collection", e);
callbackContext.error(e.getMessage());
}
};

if (setOptions == null) {
documentReference.set(JSONHelper.toSettableMap(data)).addOnSuccessListener(onSuccessListener).addOnFailureListener(onFailureListener);
} else {
documentReference.set(JSONHelper.toSettableMap(data), setOptions).addOnSuccessListener(onSuccessListener).addOnFailureListener(onFailureListener);
}
} catch (Exception e) {
Log.e(FirestorePlugin.TAG, "Error processing document of sub collection set in thread", e);
callbackContext.error(e.getMessage());
}
} catch (JSONException e) {
Log.e(FirestorePlugin.TAG, "Error processing document of sub collection set", e);
callbackContext.error(e.getMessage());
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package uk.co.reallysmall.cordova.plugin.firestore;

import android.support.annotation.NonNull;
import android.util.Log;

import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;

import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;


public class DocOfSubCollectionUpdateHandler implements ActionHandler {
private FirestorePlugin firestorePlugin;

public DocOfSubCollectionUpdateHandler(FirestorePlugin firestorePlugin) {
this.firestorePlugin = firestorePlugin;
}

@Override
public boolean handle(JSONArray args, final CallbackContext callbackContext) {
try {
final String collection = args.getString(0);
final String docId = args.getString(1);
final String subCollection = args.getString(2);
final String docOfSubCollectionId = args.getString(3);
final JSONObject data = args.getJSONObject(4);

Log.d(FirestorePlugin.TAG, "Updating document of sub collection");

try {
firestorePlugin.getDatabase().collection(collection).document(docId).collection(subCollection).document(docOfSubCollectionId).update(JSONHelper.toSettableMap(data)).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
callbackContext.success();
Log.d(FirestorePlugin.TAG, "Successfully updated document of sub collection");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
callbackContext.error(e.getMessage());
Log.w(FirestorePlugin.TAG, "Error updating document of sub collection", e);
}
});
} catch (Exception e) {
Log.e(FirestorePlugin.TAG, "Error processing document of sub collection update in thread", e);
callbackContext.error(e.getMessage());
}
;
} catch (JSONException e) {
Log.e(FirestorePlugin.TAG, "Error processing document of sub collection update", e);
callbackContext.error(e.getMessage());
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
handlers.put("collectionUnsubscribe", new CollectionUnsubscribeHandler(this));
handlers.put("collectionAdd", new CollectionAddHandler(this));
handlers.put("collectionGet", new CollectionGetHandler(this));
handlers.put("initialise", new InitialiseHandler(this));
handlers.put("initialise", new InitialiseHandler(webView.getContext().getApplicationContext(), this));
handlers.put("docSet", new DocSetHandler(this));
handlers.put("docUpdate", new DocUpdateHandler(this));
handlers.put("docOnSnapshot", new DocOnSnapshotHandler(this));
Expand All @@ -45,6 +45,12 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
handlers.put("transactionDocSet", new TransactionDocSetHandler(this));
handlers.put("transactionDocDelete", new TransactionDocDeleteHandler(this));
handlers.put("transactionResolve", new TransactionResolveHandler(this));
handlers.put("logEvent", new LogEventHandler(webView.getContext().getApplicationContext(),this));
handlers.put("docOfSubCollectionSet", new DocOfSubCollectionSetHandler(this));
handlers.put("docOfSubCollectionGet", new DocOfSubCollectionGetHandler(this));
handlers.put("docOfSubCollectionUpdate", new DocOfSubCollectionUpdateHandler(this));
handlers.put("docOfSubCollectionDelete", new DocOfSubCollectionDeleteHandler(this));
handlers.put("subCollectionGet", new SubCollectionGetHandler(this));

Log.d(TAG, "Initializing FirestorePlugin");
}
Expand Down
Loading