From 7733c535db04fb4ec31b73eba25c20fc3ab75ed7 Mon Sep 17 00:00:00 2001 From: Matt Jeanes Date: Fri, 7 Oct 2016 10:31:49 -0400 Subject: [PATCH 1/3] Fix Android Storage, allow config via .json file --- .../java/io/fullstack/firestack/FirestackStorage.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/io/fullstack/firestack/FirestackStorage.java b/android/src/main/java/io/fullstack/firestack/FirestackStorage.java index 4de1f3c..a76e14b 100644 --- a/android/src/main/java/io/fullstack/firestack/FirestackStorage.java +++ b/android/src/main/java/io/fullstack/firestack/FirestackStorage.java @@ -60,14 +60,16 @@ public String getName() { } @ReactMethod - public void downloadUrl(final String storageUrl, + public void downloadUrl(final String javascriptStorageBucket, final String path, final Callback callback) { FirebaseStorage storage = FirebaseStorage.getInstance(); + String storageBucket = storage.getApp().getOptions().getStorageBucket(); + String storageUrl = "gs://"+storageBucket; StorageReference storageRef = storage.getReferenceFromUrl(storageUrl); - StorageReference fileRef = storageRef.child(path); + StorageReference fileRef = storageRef.child(path); - Task downloadTask = storageRef.getDownloadUrl(); + Task downloadTask = fileRef.getDownloadUrl(); downloadTask.addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(Uri uri) { From 539f38535674c9767f4ea34899abdd0de836e3aa Mon Sep 17 00:00:00 2001 From: Matt Jeanes Date: Fri, 7 Oct 2016 10:51:38 -0400 Subject: [PATCH 2/3] Update README to include info about google-services.json --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c07ed00..98d56b3 100644 --- a/README.md +++ b/README.md @@ -200,10 +200,31 @@ Lastly, due to some dependencies requirements, Firestack supports iOS versions 8 ### Android -There are several ways to setup Firebase on Android. The _easiest_ way is to pass the configuration settings in JavaScript. In that way, there is no setup for the native platform. +There are several ways to setup Firebase on Android. The _easiest_ way is to pass the configuration settings in JavaScript. In that way, there is no setup for the native platform. +#### google-services.json setup If you prefer to include the default settings in the source of your app, download the `google-services.json` file provided by Firebase in the _Add Firebase to Android_ platform menu in your Firebase configuration console. +Next you'll have to add the google-services gradle plugin in order to parse it. + +Add the google-services gradle plugin as a dependency in the *project* level build.gradle +`android/build.gradle` +```java +buildscript { + // ... + dependencies { + // ... + classpath 'com.google.gms:google-services:3.0.0' + } +} +``` + +In your app build.gradle file, add the gradle plugin at the VERY BOTTOM of the file (below all dependencies) +`android/app/build.gradle` +```java +apply plugin: 'com.google.gms.google-services' +``` + ## Usage After creating a Firebase project and installing the library, we can use it in our project by importing the library in our JavaScript: From 7434da28b142ac0a2ccdcee255c66b6206c13a30 Mon Sep 17 00:00:00 2001 From: Matt Jeanes Date: Fri, 7 Oct 2016 10:52:41 -0400 Subject: [PATCH 3/3] Bugfix in configuration using google-services.json --- .../src/main/java/io/fullstack/firestack/FirestackModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/io/fullstack/firestack/FirestackModule.java b/android/src/main/java/io/fullstack/firestack/FirestackModule.java index 21315ec..3bd06e4 100644 --- a/android/src/main/java/io/fullstack/firestack/FirestackModule.java +++ b/android/src/main/java/io/fullstack/firestack/FirestackModule.java @@ -66,7 +66,7 @@ public String setKeyOrDefault( final String val = params.getString(key); Log.d(TAG, "Setting " + key + " from params to: " + val); return val; - } else if (defaultValue != null && defaultValue != "") { + } else if (defaultValue != null && !defaultValue.equals("")) { Log.d(TAG, "Setting " + key + " from params to: " + defaultValue); return defaultValue; } else {