本文整理汇总了Java中com.google.firebase.auth.PhoneAuthProvider.ForceResendingToken方法的典型用法代码示例。如果您正苦于以下问题:Java PhoneAuthProvider.ForceResendingToken方法的具体用法?Java PhoneAuthProvider.ForceResendingToken怎么用?Java PhoneAuthProvider.ForceResendingToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.auth.PhoneAuthProvider
的用法示例。
在下文中一共展示了PhoneAuthProvider.ForceResendingToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resendVerificationCode
import com.google.firebase.auth.PhoneAuthProvider; //导入方法依赖的package包/类
private void resendVerificationCode(String phoneNumber,
PhoneAuthProvider.ForceResendingToken token) {
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks, // OnVerificationStateChangedCallbacks
token); // ForceResendingToken from callbacks
}
示例2: onCreate
import com.google.firebase.auth.PhoneAuthProvider; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_otp);
sentNumber="INVALID";
//Check for the OTP
mCallbacks=new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
sentNumber=phoneAuthCredential.getSmsCode();
Toasty.success(OTP.this, "Verification Success", Toast.LENGTH_SHORT).show();
moveToNextActivity();
}
@Override
public void onVerificationFailed(FirebaseException e) {
Toasty.error(OTP.this, "Invalid OTP", Toast.LENGTH_SHORT).show();
}
@Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// Log.d(TAG, "onCodeSent:" + verificationId);
Toasty.info(OTP.this, "OTP has been send to your number", Toast.LENGTH_SHORT).show();
// Save verification ID and resending token so we can use them later
mVerificationId = verificationId;
mResendToken = token;
}
};
//Phone Auth Parameters
PhoneAuthProvider.getInstance().verifyPhoneNumber(
LocalDB.getPhoneNumber(),
60,
java.util.concurrent.TimeUnit.SECONDS,
OTP.this,
mCallbacks);
if(!isNetworkAvailable())
{
Toasty.warning(OTP.this,"Please Check Your Internet Connection and Try Again", Toast.LENGTH_SHORT).show();
}
}
示例3: verifyPhoneNumber
import com.google.firebase.auth.PhoneAuthProvider; //导入方法依赖的package包/类
private void verifyPhoneNumber(String phoneNumber){
if (!isValid){
Toast.makeText(this, "Invalid Phone number!", Toast.LENGTH_SHORT).show();
return;
}
hud.show();
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
// This callback will be invoked in two situations:
// 1 - Instant verification. In some cases the phone number can be instantly
// verified without needing to send or enter a verification code.
// 2 - Auto-retrieval. On some devices Google Play services can automatically
// detect the incoming verification SMS and perform verification without
// user action.
Log.d(TAG, "onVerificationCompleted:" + credential);
hud.dismiss();
signInWithPhoneAuthCredential(credential);
}
@Override
public void onVerificationFailed(FirebaseException e) {
// This callback is invoked in an invalid request for verification is made,
// for instance if the the phone number format is not valid.
Toast.makeText(RegisterPhoneActivity.this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
Toast.makeText(RegisterPhoneActivity.this, "Invalid mobile number", Toast.LENGTH_SHORT).show();
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
Toast.makeText(RegisterPhoneActivity.this, "The SMS quota for the project has been exceeded", Toast.LENGTH_SHORT).show();
}
// Show a message and update the UI
hud.dismiss();
}
@Override
public void onCodeSent(String verificationId,
PhoneAuthProvider.ForceResendingToken token) {
// The SMS verification code has been sent to the provided phone number, we
// now need to ask the user to enter the code and then construct a credential
// by combining the code with a verification ID.
Log.d(TAG, "onCodeSent:" + verificationId);
// Save verification ID and resending token so we can use them later
phoneVerficationID = verificationId;
resendToken = token;
Toast.makeText(RegisterPhoneActivity.this, getString(R.string.register_verify_sent), Toast.LENGTH_SHORT).show();
hud.dismiss();
startResendTimer();
}
};
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber,
60,
TimeUnit.SECONDS,
this,
mCallbacks);
}