From 0c550f3586293af2ffcab46ad61fd8a6e9dbed7f Mon Sep 17 00:00:00 2001 From: Elton Gao Date: Thu, 9 Nov 2017 10:34:52 -0500 Subject: [PATCH 1/2] Make sure the promise is resolved/rejected for transaction Right now the following code will be broken: ``` async function() { await ref.transaction( function(foo) { // deal with foo }, function(error, committed, ss) { // additional work on complete callback }, true ); // NOTE: Code from here will never execute because promise above never gets resolved } ``` v2 is not returning at the point of calling onComplete, v3 code does --- lib/modules/database/reference.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/modules/database/reference.js b/lib/modules/database/reference.js index ffb1af9f..83f535ac 100644 --- a/lib/modules/database/reference.js +++ b/lib/modules/database/reference.js @@ -195,8 +195,11 @@ export default class Reference extends ReferenceBase { return new Promise((resolve, reject) => { const onCompleteWrapper = (error, committed, snapshotData) => { if (isFunction(onComplete)) { - if (error) return onComplete(error, committed, null); - return onComplete(null, committed, new Snapshot(this, snapshotData)); + if (error) { + onComplete(error, committed, null); + } else { + onComplete(null, committed, new Snapshot(this, snapshotData)); + } } if (error) return reject(error); From 802c54ade8e6f2bde822066b2f9c77d074be7679 Mon Sep 17 00:00:00 2001 From: Akshet Pandey Date: Mon, 20 Nov 2017 16:58:55 -0800 Subject: [PATCH 2/2] [android][messaging] Handle SecuritException in cancelAllLocalNotifications --- .../invertase/firebase/messaging/RNFirebaseMessaging.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java b/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java index 87fa616e..bc6d1d7b 100644 --- a/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java +++ b/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java @@ -104,7 +104,13 @@ public class RNFirebaseMessaging extends ReactContextBaseJavaModule implements L @ReactMethod public void cancelAllLocalNotifications() { - mRNFirebaseLocalMessagingHelper.cancelAllLocalNotifications(); + try { + mRNFirebaseLocalMessagingHelper.cancelAllLocalNotifications(); + } catch (SecurityException e) { + // In some devices/situations cancelAllLocalNotifications will throw a SecurityException + // We can safely ignore this error for now as the UX impact of this not working is minor. + Log.w(TAG, e.getMessage()); + } } @ReactMethod