|
1 | 1 | package com.gds.quickfirebase; |
2 | 2 |
|
3 | 3 | import android.annotation.SuppressLint; |
4 | | -import android.app.Activity; |
5 | | -import android.support.annotation.NonNull; |
| 4 | +import androidx.annotation.NonNull; |
6 | 5 | import android.os.Bundle; |
7 | 6 | import android.text.TextUtils; |
8 | 7 | import com.facebook.react.bridge.Arguments; |
|
20 | 19 | import com.google.firebase.auth.FirebaseAuth; |
21 | 20 | import com.google.firebase.auth.FirebaseUser; |
22 | 21 | import com.google.firebase.auth.PhoneAuthCredential; |
| 22 | +import com.google.firebase.auth.PhoneAuthOptions; |
23 | 23 | import com.google.firebase.auth.PhoneAuthProvider; |
24 | 24 |
|
25 | 25 | import java.util.concurrent.TimeUnit; |
@@ -52,28 +52,27 @@ public String getName() { |
52 | 52 |
|
53 | 53 | @ReactMethod |
54 | 54 | 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() { |
61 | 58 | @Override |
62 | | - public void onVerificationCompleted(PhoneAuthCredential credential) { |
| 59 | + public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential) { |
| 60 | + |
63 | 61 | } |
64 | 62 |
|
65 | 63 | @Override |
66 | | - public void onVerificationFailed(FirebaseException e) { |
| 64 | + public void onVerificationFailed(@NonNull FirebaseException e) { |
67 | 65 | promise.reject(e); |
68 | 66 | } |
69 | 67 |
|
70 | 68 | @Override |
71 | | - public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken token) { |
| 69 | + public void onCodeSent(@NonNull String verificationId, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) { |
72 | 70 | promise.resolve(verificationId); |
73 | 71 | mVerificationId = verificationId; |
74 | | - mResendToken = token; |
| 72 | + mResendToken = forceResendingToken; |
75 | 73 | } |
76 | | - }); |
| 74 | + }).build(); |
| 75 | + PhoneAuthProvider.verifyPhoneNumber(phoneAuthOptions); |
77 | 76 | } |
78 | 77 |
|
79 | 78 | @ReactMethod |
|
0 commit comments