From 15992f3ba92c7294ef2039f328ebf5852babc4e1 Mon Sep 17 00:00:00 2001 From: Salakar Date: Sat, 12 May 2018 23:13:54 +0100 Subject: [PATCH] [android][auth] add sendSignInLinkToEmail native method --- .../firebase/auth/RNFirebaseAuth.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java b/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java index f6767a32..d4109d52 100644 --- a/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java +++ b/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java @@ -387,6 +387,39 @@ class RNFirebaseAuth extends ReactContextBaseJavaModule { } } + /** + * sendSignInLinkToEmail + * + * @param email + * @param promise + */ + @ReactMethod + public void sendSignInLinkToEmail(String appName, String email, ReadableMap actionCodeSettings, final Promise promise) { + Log.d(TAG, "sendSignInLinkToEmail"); + FirebaseApp firebaseApp = FirebaseApp.getInstance(appName); + FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(firebaseApp); + + OnCompleteListener listener = new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (task.isSuccessful()) { + Log.d(TAG, "sendSignInLinkToEmail:onComplete:success"); + promiseNoUser(promise, false); + } else { + Exception exception = task.getException(); + Log.e(TAG, "sendSignInLinkToEmail:onComplete:failure", exception); + promiseRejectAuthException(promise, exception); + } + } + }; + + + ActionCodeSettings settings = buildActionCodeSettings(actionCodeSettings); + firebaseAuth.sendSignInLinkToEmail(email, settings).addOnCompleteListener(listener); + } + + + /* ---------------------- * .currentUser methods * ---------------------- */