Commit 3412255e authored by Stanislav Shakirov's avatar Stanislav Shakirov Committed by GitHub

save FirebaseInstanceId.getInstance() access.

`FirebaseInstanceId.getInstance()` can throw exceptions. For example if Firebase was not initialized.
parent dfc91524
...@@ -70,8 +70,13 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li ...@@ -70,8 +70,13 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
@ReactMethod @ReactMethod
public void getFCMToken(Promise promise) { public void getFCMToken(Promise promise) {
try {
Log.d(TAG, "Firebase token: " + FirebaseInstanceId.getInstance().getToken()); Log.d(TAG, "Firebase token: " + FirebaseInstanceId.getInstance().getToken());
promise.resolve(FirebaseInstanceId.getInstance().getToken()); promise.resolve(FirebaseInstanceId.getInstance().getToken());
} catch (Throwable e) {
e.printStackTrace();
promise.reject(null,e.getMessage());
}
} }
@ReactMethod @ReactMethod
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment