From 90efc3dad4f45cfb479978ce478be40391ec6b41 Mon Sep 17 00:00:00 2001 From: Ali Al Amine Date: Thu, 30 Mar 2017 17:16:52 +0300 Subject: [PATCH] Fixes the crash when the user opens the app while offline --- .../java/io/fullstack/firestack/FirestackAuth.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/io/fullstack/firestack/FirestackAuth.java b/android/src/main/java/io/fullstack/firestack/FirestackAuth.java index 676b27f..5245daf 100644 --- a/android/src/main/java/io/fullstack/firestack/FirestackAuth.java +++ b/android/src/main/java/io/fullstack/firestack/FirestackAuth.java @@ -598,7 +598,16 @@ public void userExceptionCallback(Exception exp, final Callback onFail) { Log.e(TAG, ex.getMessage()); } - onFail.invoke(error); + try { + onFail.invoke(error); + } catch (RuntimeException ex) { + // Firebase tries to login 3 times, so the callback might + // be called as much as that. This will prevent a crash in case + // the callback throws the following error: + // java.lang.RuntimeException: Illegal callback invocation from native module. This callback type only permits a single invocation from native code. + Log.e(TAG, ex.getMessage()); + } + } private WritableMap getUserMap() {