I'm trying to implement Firebase phone number authentication. Official docs says that I need to call
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
And pass my activity reference for callback binding.
There is another overloaded method in docs, which accepts TaskExecutors.MAIN_THREAD
(the Executor used to call the OnVerificationStateChangedCallbacks
callbacks), instead of activity ref.
That's what I needed. In this case
phoneAuthProvider.verifyPhoneNumber(
phone,
1,
TimeUnit.MINUTES,
TaskExecutors.MAIN_THREAD,
callbacks,
resendingToken
);
The code works perfectly. But the problem is: callbacks continue their work in a background infinitely long. I didn't find any methods in the documentation to stop these callbacks.
So, how can I manually remove these callbacks, when I don't need them anymore?
I think you can use TaskExecutors.MAIN_THREAD instead.
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
TaskExecutors.MAIN_THREAD, // Executor
verifyNumberCallback
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With