Skip to content

Commit 4ddee42

Browse files
authored
Update RNQuickFirebase.java remove deprecated function for PhoneAuth
1 parent 7581543 commit 4ddee42

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

android/src/main/java/com/gds/quickfirebase/RNQuickFirebase.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.gds.quickfirebase;
22

33
import android.annotation.SuppressLint;
4-
import android.app.Activity;
5-
import android.support.annotation.NonNull;
4+
import androidx.annotation.NonNull;
65
import android.os.Bundle;
76
import android.text.TextUtils;
87
import com.facebook.react.bridge.Arguments;
@@ -20,6 +19,7 @@
2019
import com.google.firebase.auth.FirebaseAuth;
2120
import com.google.firebase.auth.FirebaseUser;
2221
import com.google.firebase.auth.PhoneAuthCredential;
22+
import com.google.firebase.auth.PhoneAuthOptions;
2323
import com.google.firebase.auth.PhoneAuthProvider;
2424

2525
import java.util.concurrent.TimeUnit;
@@ -52,28 +52,27 @@ public String getName() {
5252

5353
@ReactMethod
5454
public void sendOTP(String phone, final Promise promise) {
55-
PhoneAuthProvider.getInstance().verifyPhoneNumber(
56-
phone, // Phone number to verify
57-
60, // Timeout duration
58-
TimeUnit.SECONDS, // Unit of timeout
59-
reactContext.getCurrentActivity(), // Activity (for callback binding)
60-
new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
55+
PhoneAuthOptions phoneAuthOptions = new PhoneAuthOptions.Builder(mAuth).setPhoneNumber(phone)
56+
.setTimeout(60L, TimeUnit.SECONDS).setActivity(reactContext.getCurrentActivity())
57+
.setCallbacks(new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
6158
@Override
62-
public void onVerificationCompleted(PhoneAuthCredential credential) {
59+
public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential) {
60+
6361
}
6462

6563
@Override
66-
public void onVerificationFailed(FirebaseException e) {
64+
public void onVerificationFailed(@NonNull FirebaseException e) {
6765
promise.reject(e);
6866
}
6967

7068
@Override
71-
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken token) {
69+
public void onCodeSent(@NonNull String verificationId, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) {
7270
promise.resolve(verificationId);
7371
mVerificationId = verificationId;
74-
mResendToken = token;
72+
mResendToken = forceResendingToken;
7573
}
76-
});
74+
}).build();
75+
PhoneAuthProvider.verifyPhoneNumber(phoneAuthOptions);
7776
}
7877

7978
@ReactMethod

0 commit comments

Comments
 (0)