From 78262dcb32c2dd26ff378a6c407a9bc476e5e29e Mon Sep 17 00:00:00 2001 From: Daehoon Kim Date: Mon, 26 Jun 2017 14:30:17 +0900 Subject: [PATCH 01/15] Support javascript plain error object in crash.report --- lib/modules/crash/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/crash/index.js b/lib/modules/crash/index.js index 63cfa7e7..2b36553f 100644 --- a/lib/modules/crash/index.js +++ b/lib/modules/crash/index.js @@ -56,7 +56,7 @@ export default class Crash { * @param maxStackSize */ report(error: FirebaseError, maxStackSize: number = 10): void { - if (!error || !error.code || !error.message) return; + if (!error || !error.message) return; let errorMessage = `Message: ${error.message}\r\n`; From 848ea4203cd70ba875e9e98a01b7ce1f51ed6bfc Mon Sep 17 00:00:00 2001 From: ehacinom Date: Tue, 27 Jun 2017 00:22:24 -0500 Subject: [PATCH 02/15] fixed dead link to authentication#user --- docs/modules/authentication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/authentication.md b/docs/modules/authentication.md index 9b535fdd..ac6c0a73 100644 --- a/docs/modules/authentication.md +++ b/docs/modules/authentication.md @@ -9,7 +9,7 @@ RNFirebase handles authentication for us out of the box, both with email/passwor ### Properties ##### `authenticated: boolean` - Returns the current Firebase authentication state. -##### `currentUser: User | null` - Returns the currently signed-in user (or null). See the [User](/docs/api/authentication.md#user) class documentation for further usage. +##### `currentUser: User | null` - Returns the currently signed-in user (or null). See the [User](/modules/authentication.md#user) class documentation for further usage. ### Methods From 946736b0c9a8db516639c3e07e604be7ba83f424 Mon Sep 17 00:00:00 2001 From: Nicolas Beck Date: Tue, 27 Jun 2017 20:41:13 +0200 Subject: [PATCH 03/15] update file upload error handling docs --- docs/modules/storage.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/modules/storage.md b/docs/modules/storage.md index 757008af..c3d341e2 100644 --- a/docs/modules/storage.md +++ b/docs/modules/storage.md @@ -34,18 +34,20 @@ firebase.storage() ### Listen to upload state ```javascript -const unsubscribe = firebase.storage() +const uploadTask = firebase.storage() .ref('/files/1234') - .putFile('/path/to/file/1234') - .on('state_changed', snapshot => { + .putFile('/path/to/file/1234'); + +const unsubscribe = uploadTask.on('state_changed', snapshot => { //Current upload state - }, err => { - //Error - unsubscribe(); - }, uploadedFile => { + }, null, uploadedFile => { //Success unsubscribe(); }); +uploadTask.catch(err => { + //Error + unsubscribe(); + }); ``` ## Downloading files From ead50944f5caba367d1eb12c9293e10cb32e8dad Mon Sep 17 00:00:00 2001 From: Nicolas Beck Date: Tue, 27 Jun 2017 20:41:42 +0200 Subject: [PATCH 04/15] added newline --- docs/modules/storage.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/modules/storage.md b/docs/modules/storage.md index c3d341e2..55a59597 100644 --- a/docs/modules/storage.md +++ b/docs/modules/storage.md @@ -44,6 +44,7 @@ const unsubscribe = uploadTask.on('state_changed', snapshot => { //Success unsubscribe(); }); + uploadTask.catch(err => { //Error unsubscribe(); From d77dd094db0af7f8c36c7e3d3389d0ad2f528597 Mon Sep 17 00:00:00 2001 From: nico Date: Thu, 29 Jun 2017 18:12:57 +0200 Subject: [PATCH 05/15] fixed ios custom metaData --- ios/RNFirebase/storage/RNFirebaseStorage.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ios/RNFirebase/storage/RNFirebaseStorage.m b/ios/RNFirebase/storage/RNFirebaseStorage.m index d65d369f..bc1d5169 100644 --- a/ios/RNFirebase/storage/RNFirebaseStorage.m +++ b/ios/RNFirebase/storage/RNFirebaseStorage.m @@ -5,6 +5,7 @@ #import #import "Firebase.h" + @implementation RNFirebaseStorage RCT_EXPORT_MODULE(RNFirebaseStorage); @@ -154,7 +155,7 @@ RCT_EXPORT_METHOD(getMetadata: (NSString *) path resolver:(RCTPromiseResolveBloc */ RCT_EXPORT_METHOD(updateMetadata: (NSString *) path metadata:(NSDictionary *) metadata resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { FIRStorageReference *fileRef = [self getReference:path]; - FIRStorageMetadata *firmetadata = [[FIRStorageMetadata alloc] initWithDictionary:metadata]; + FIRStorageMetadata *firmetadata = [self buildMetadataFromMap:metadata]; [fileRef updateMetadata:firmetadata completion:^(FIRStorageMetadata * _Nullable metadata, NSError * _Nullable error) { if (error != nil) { @@ -317,14 +318,14 @@ RCT_EXPORT_METHOD(putFile:(NSString *) path localPath:(NSString *)localPath meta - (void) uploadFile:(NSURL *) url metadata:(NSDictionary *) metadata path:(NSString *) path resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject { FIRStorageReference *fileRef = [self getReference:path]; - FIRStorageMetadata *firmetadata = [[FIRStorageMetadata alloc] initWithDictionary:metadata]; + FIRStorageMetadata *firmetadata = [self buildMetadataFromMap:metadata]; FIRStorageUploadTask *uploadTask = [fileRef putFile:url metadata:firmetadata]; [self addUploadObservers:uploadTask path:path resolver:resolve rejecter:reject]; } - (void) uploadData:(NSData *) data metadata:(NSDictionary *) metadata path:(NSString *) path resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject{ FIRStorageReference *fileRef = [self getReference:path]; - FIRStorageMetadata *firmetadata = [[FIRStorageMetadata alloc] initWithDictionary:metadata]; + FIRStorageMetadata *firmetadata = [self buildMetadataFromMap:metadata]; FIRStorageUploadTask *uploadTask = [fileRef putData:data metadata:firmetadata]; [self addUploadObservers:uploadTask path:path resolver:resolve rejecter:reject]; } @@ -394,6 +395,13 @@ RCT_EXPORT_METHOD(putFile:(NSString *) path localPath:(NSString *)localPath meta }; } +- (FIRStorageMetadata *)buildMetadataFromMap:(NSDictionary *)metadata { + NSMutableDictionary *result = [metadata mutableCopy]; + result[@"metadata"] = metadata[@"customMetadata"]; + [result removeObjectForKey:@"customMetadata"]; + return [[FIRStorageMetadata alloc] initWithDictionary:result]; +} + - (NSString *)getTaskStatus:(FIRStorageTaskStatus)status { if (status == FIRStorageTaskStatusResume || status == FIRStorageTaskStatusProgress) { return @"running"; From 1f61933d656f2d6cc033346a99ed0b0f3b4d4653 Mon Sep 17 00:00:00 2001 From: nico Date: Thu, 29 Jun 2017 18:27:47 +0200 Subject: [PATCH 06/15] removed newline --- ios/RNFirebase/storage/RNFirebaseStorage.m | 1 - 1 file changed, 1 deletion(-) diff --git a/ios/RNFirebase/storage/RNFirebaseStorage.m b/ios/RNFirebase/storage/RNFirebaseStorage.m index bc1d5169..f4ceacb6 100644 --- a/ios/RNFirebase/storage/RNFirebaseStorage.m +++ b/ios/RNFirebase/storage/RNFirebaseStorage.m @@ -5,7 +5,6 @@ #import #import "Firebase.h" - @implementation RNFirebaseStorage RCT_EXPORT_MODULE(RNFirebaseStorage); From 96b4a47a523d83e8d077bfc29588de075838e347 Mon Sep 17 00:00:00 2001 From: nico Date: Thu, 29 Jun 2017 18:30:52 +0200 Subject: [PATCH 07/15] reverted local docs change --- docs/modules/storage.md | 87 ++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 45 deletions(-) diff --git a/docs/modules/storage.md b/docs/modules/storage.md index 55a59597..2371ff3d 100644 --- a/docs/modules/storage.md +++ b/docs/modules/storage.md @@ -9,14 +9,14 @@ providing some iOS and Android specific functionality. ```javascript firebase.storage() - .ref('/files/1234') - .putFile('/path/to/file/1234') - .then(uploadedFile => { - //success - }) - .catch(err => { - //Error - }); +.ref('/files/1234') +.putFile('/path/to/file/1234') +.then(uploadedFile => { +//success +}) +.catch(err => { +//Error +}); ``` @@ -24,31 +24,28 @@ firebase.storage() ```javascript const metadata = { - contentType: 'image/jpeg' +contentType: 'image/jpeg' } firebase.storage() - .ref('/files/1234') - .putFile('/path/to/file/1234', metadata) +.ref('/files/1234') +.putFile('/path/to/file/1234', metadata) ``` ### Listen to upload state ```javascript -const uploadTask = firebase.storage() - .ref('/files/1234') - .putFile('/path/to/file/1234'); - -const unsubscribe = uploadTask.on('state_changed', snapshot => { - //Current upload state - }, null, uploadedFile => { - //Success - unsubscribe(); - }); - -uploadTask.catch(err => { - //Error - unsubscribe(); - }); +const unsubscribe = firebase.storage() +.ref('/files/1234') +.putFile('/path/to/file/1234') +.on('state_changed', snapshot => { +//Current upload state +}, err => { +//Error +unsubscribe(); +}, uploadedFile => { +//Success +unsubscribe(); +}); ``` ## Downloading files @@ -57,31 +54,31 @@ uploadTask.catch(err => { ```javascript firebase.storage() - .ref('/files/1234') - .downloadFile('/path/to/save/file') - .then(downloadedFile => { - //success - }) - .catch(err => { - //Error - }); +.ref('/files/1234') +.downloadFile('/path/to/save/file') +.then(downloadedFile => { +//success +}) +.catch(err => { +//Error +}); ``` ### Listen to download state ```javascript const unsubscribe = firebase.storage() - .ref('/files/1234') - .downloadFile('/path/to/save/file') - .on('state_changed', snapshot => { - //Current download state - }, err => { - //Error - unsubscribe(); - }, downloadedFile => { - //Success - unsubscribe(); - }); +.ref('/files/1234') +.downloadFile('/path/to/save/file') +.on('state_changed', snapshot => { +//Current download state +}, err => { +//Error +unsubscribe(); +}, downloadedFile => { +//Success +unsubscribe(); +}); ``` ## TODO From 0f11da0e0b9c71ab5d7292684e7910e50a990531 Mon Sep 17 00:00:00 2001 From: nico Date: Thu, 29 Jun 2017 18:33:43 +0200 Subject: [PATCH 08/15] whitespace --- docs/modules/storage.md | 82 ++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/docs/modules/storage.md b/docs/modules/storage.md index 2371ff3d..757008af 100644 --- a/docs/modules/storage.md +++ b/docs/modules/storage.md @@ -9,14 +9,14 @@ providing some iOS and Android specific functionality. ```javascript firebase.storage() -.ref('/files/1234') -.putFile('/path/to/file/1234') -.then(uploadedFile => { -//success -}) -.catch(err => { -//Error -}); + .ref('/files/1234') + .putFile('/path/to/file/1234') + .then(uploadedFile => { + //success + }) + .catch(err => { + //Error + }); ``` @@ -24,28 +24,28 @@ firebase.storage() ```javascript const metadata = { -contentType: 'image/jpeg' + contentType: 'image/jpeg' } firebase.storage() -.ref('/files/1234') -.putFile('/path/to/file/1234', metadata) + .ref('/files/1234') + .putFile('/path/to/file/1234', metadata) ``` ### Listen to upload state ```javascript const unsubscribe = firebase.storage() -.ref('/files/1234') -.putFile('/path/to/file/1234') -.on('state_changed', snapshot => { -//Current upload state -}, err => { -//Error -unsubscribe(); -}, uploadedFile => { -//Success -unsubscribe(); -}); + .ref('/files/1234') + .putFile('/path/to/file/1234') + .on('state_changed', snapshot => { + //Current upload state + }, err => { + //Error + unsubscribe(); + }, uploadedFile => { + //Success + unsubscribe(); + }); ``` ## Downloading files @@ -54,31 +54,31 @@ unsubscribe(); ```javascript firebase.storage() -.ref('/files/1234') -.downloadFile('/path/to/save/file') -.then(downloadedFile => { -//success -}) -.catch(err => { -//Error -}); + .ref('/files/1234') + .downloadFile('/path/to/save/file') + .then(downloadedFile => { + //success + }) + .catch(err => { + //Error + }); ``` ### Listen to download state ```javascript const unsubscribe = firebase.storage() -.ref('/files/1234') -.downloadFile('/path/to/save/file') -.on('state_changed', snapshot => { -//Current download state -}, err => { -//Error -unsubscribe(); -}, downloadedFile => { -//Success -unsubscribe(); -}); + .ref('/files/1234') + .downloadFile('/path/to/save/file') + .on('state_changed', snapshot => { + //Current download state + }, err => { + //Error + unsubscribe(); + }, downloadedFile => { + //Success + unsubscribe(); + }); ``` ## TODO From 2129f32db6320d3c41f100b14c46b42ed821d384 Mon Sep 17 00:00:00 2001 From: nico1510 Date: Thu, 29 Jun 2017 19:32:40 +0200 Subject: [PATCH 09/15] fixed customMetadata android --- .../firebase/storage/RNFirebaseStorage.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java b/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java index 4e2abbf3..9e68124c 100644 --- a/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java +++ b/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java @@ -7,6 +7,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.HashMap; @@ -428,10 +429,26 @@ public class RNFirebaseStorage extends ReactContextBaseJavaModule { */ private StorageMetadata buildMetadataFromMap(ReadableMap metadata) { StorageMetadata.Builder metadataBuilder = new StorageMetadata.Builder(); - Map m = Utils.recursivelyDeconstructReadableMap(metadata); - for (Map.Entry entry : m.entrySet()) { - metadataBuilder.setCustomMetadata(entry.getKey(), entry.getValue().toString()); + try { + + Map m = Utils.recursivelyDeconstructReadableMap(metadata); + + Map customMetadata = (Map) m.get("customMetadata"); + if (customMetadata != null) { + for (Map.Entry entry : customMetadata.entrySet()) { + metadataBuilder.setCustomMetadata(entry.getKey(), String.valueOf(entry.getValue())); + } + } + + metadataBuilder.setCacheControl((String) m.get("cacheControl")); + metadataBuilder.setContentDisposition((String) m.get("contentDisposition")); + metadataBuilder.setContentEncoding((String) m.get("contentEncoding")); + metadataBuilder.setContentLanguage((String) m.get("contentLanguage")); + metadataBuilder.setContentType((String) m.get("contentType")); + + } catch (Exception e) { + Log.e(TAG, "error while building meta data " + e.getMessage()); } return metadataBuilder.build(); From e4c61f61da6df269e6622c8e54cdc530d9d0309c Mon Sep 17 00:00:00 2001 From: nico1510 Date: Thu, 29 Jun 2017 19:34:15 +0200 Subject: [PATCH 10/15] removed unused import --- .../java/io/invertase/firebase/storage/RNFirebaseStorage.java | 1 - 1 file changed, 1 deletion(-) diff --git a/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java b/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java index 9e68124c..f9ad810a 100644 --- a/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java +++ b/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java @@ -7,7 +7,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.HashMap; From 5a7d15f5419a08ef2ff85e28789fe00e8a191486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Anh=20Tu=E1=BA=A5n?= Date: Fri, 30 Jun 2017 08:12:39 +0700 Subject: [PATCH 11/15] Update installation-ios.md Update cocoapods libs to latest version before do install. --- docs/installation-ios.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation-ios.md b/docs/installation-ios.md index 0a02c2fb..83ceb451 100644 --- a/docs/installation-ios.md +++ b/docs/installation-ios.md @@ -19,7 +19,7 @@ Unfortunately, due to the fact that Firebase is much easier to setup using Cocoa ### 2.0) If you don't already have Cocoapods set up Follow the instructions to install Cocoapods and create your Podfile [here](https://firebase.google.com/docs/ios/setup#add_the_sdk). -**NOTE: The Podfile needs to be initialised in the `ios` directory of your project.** +**NOTE: The Podfile needs to be initialised in the `ios` directory of your project and do update cocoapods libs first `pod update`** #### Troubleshooting 1) When running `pod install` you may encounter an error saying that a `tvOSTests` target is declared twice. This appears to be a bug with `pod init` and the way that react native is set up. From 8c3e6b29e255c17d833ef50dfa36ff722b6494fd Mon Sep 17 00:00:00 2001 From: Michael Diarmid Date: Fri, 30 Jun 2017 14:18:10 +0100 Subject: [PATCH 12/15] Update installation-ios.md --- docs/installation-ios.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation-ios.md b/docs/installation-ios.md index 83ceb451..159541ed 100644 --- a/docs/installation-ios.md +++ b/docs/installation-ios.md @@ -19,7 +19,7 @@ Unfortunately, due to the fact that Firebase is much easier to setup using Cocoa ### 2.0) If you don't already have Cocoapods set up Follow the instructions to install Cocoapods and create your Podfile [here](https://firebase.google.com/docs/ios/setup#add_the_sdk). -**NOTE: The Podfile needs to be initialised in the `ios` directory of your project and do update cocoapods libs first `pod update`** +**NOTE: The Podfile needs to be initialised in the `ios` directory of your project. Make sure to update cocoapods libs first by running `pod update`** #### Troubleshooting 1) When running `pod install` you may encounter an error saying that a `tvOSTests` target is declared twice. This appears to be a bug with `pod init` and the way that react native is set up. From d88b39db6385dad72dcc2be5588822fa022ce035 Mon Sep 17 00:00:00 2001 From: Fidan Hakaj Date: Sat, 1 Jul 2017 13:54:47 +0200 Subject: [PATCH 13/15] Update migration-guide.md --- docs/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/migration-guide.md b/docs/migration-guide.md index 9eed6f03..b9dfb71c 100644 --- a/docs/migration-guide.md +++ b/docs/migration-guide.md @@ -109,7 +109,7 @@ Add the packages to the `getPackages()` method as required: protected List getPackages() { return Arrays.asList( new MainReactPackage(), - new RNFirebasePackage(), // <-- Add this line - it's the only one that's required + new RNFirebasePackage(), // <-- Keep this line - it's the only one that's required // add these optional packages as appropriate new RNFirebaseAdMobPackage(), From 33ec34555fa9d56d1906f486020760c2b74e798b Mon Sep 17 00:00:00 2001 From: Michael Diarmid Date: Mon, 3 Jul 2017 18:44:35 +0100 Subject: [PATCH 14/15] added perf to sidebar --- docs/_sidebar.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index a9b2bbab..77386556 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -19,6 +19,7 @@ - [Remote Config](/modules/config) - [Storage](/modules/storage) - [Transactions](/modules/transactions) + - [Performance Monitoring](/modules/perf) - Other - [Project Board](https://github.com/invertase/react-native-firebase/projects) From d20aacc41575c237304d2063212daa88e722e1ca Mon Sep 17 00:00:00 2001 From: Elliot Hesp Date: Tue, 4 Jul 2017 09:38:59 +0100 Subject: [PATCH 15/15] Update testing.md --- docs/contributing/testing.md | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/docs/contributing/testing.md b/docs/contributing/testing.md index 383062db..f6e76826 100644 --- a/docs/contributing/testing.md +++ b/docs/contributing/testing.md @@ -1,3 +1,55 @@ # Testing +Currently due to the blackbox Firebase enviroment, we have found the best way to test the library is to directly test against the library using a live Firebase project. As some modules also work with the offical web SDK, we can directly compare the results against our own library. This is however restrictive as it doesn't directly test the native code/modules. Plans are in place to overhaul the entire testing setup. +## Running the test app + +For convenience all of the required NPM scripts are packaged with the main library to run the test app. + +### Step 1 - Clone + +```bash +git clone git@github.com:invertase/react-native-firebase.git +``` + +### Step 2 - Install dependencies + +```bash +npm run tests-npm-install +``` + + +### Step 3 - Install [WML](https://github.com/wix/wml) + +WML is a library which copies files & directories to a location. This allows us to copy any changes from the library directly into the tests app, so we can quickly test changes. + +```bash +npm install -g wml +``` + +### Step 4 - Start the watcher + +```bash +npm run tests-watch-init +npm run tests-watch-start +``` + +### Step 5 - Start the app + +```bash +npm run tests-packager +``` + +#### Android + +Open the `tests/android` directory from Android Studio and allow Gradle to sync. Now run the app on an emulator/device. + +#### iOS + +First install the Pods: + +``` +npm run tests-pod-install +``` + +Open the `tests/ios/ReactNativeFirebaseDemo.xcworkspace` file in XCode and build for your preffered device or simulator.