本文整理汇总了Java中com.google.firebase.auth.PhoneAuthProvider类的典型用法代码示例。如果您正苦于以下问题:Java PhoneAuthProvider类的具体用法?Java PhoneAuthProvider怎么用?Java PhoneAuthProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhoneAuthProvider类属于com.google.firebase.auth包,在下文中一共展示了PhoneAuthProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: phoneNumberVerificationCB
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void phoneNumberVerificationCB() {
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
Log.d(TAG, "onVerificationCompleted:" + credential);
credent = credential;
}
@Override
public void onVerificationFailed(FirebaseException e) {
Log.w(TAG, "onVerificationFailed", e);
if (e instanceof FirebaseAuthInvalidCredentialsException) {
// Invalid request
// ...
} else if (e instanceof FirebaseTooManyRequestsException) {
// The SMS quota for the project has been exceeded
// ...
}
}
};
}
示例2: pluginInitialize
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
@Override
protected void pluginInitialize() {
Log.d(TAG, "Starting Firebase Authentication plugin");
this.firebaseAuth = FirebaseAuth.getInstance();
this.phoneAuthProvider = PhoneAuthProvider.getInstance();
Context context = this.cordova.getActivity().getApplicationContext();
String defaultClientId = getDefaultClientId(context);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(defaultClientId)
.requestEmail()
.requestProfile()
.build();
googleApiClient = new GoogleApiClient.Builder(context)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
googleApiClient.connect();
//firebaseAuth = FirebaseAuth.getInstance();
//firebaseAuth.addAuthStateListener(this);
}
开发者ID:kanodeveloper,项目名称:cordova-plugin-firebase-performance-ka,代码行数:23,代码来源:FirebaseAuthenticationPlugin.java
示例3: providerIdToAccountType
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
/**
* Translate a Firebase Auth provider ID (such as {@link GoogleAuthProvider#PROVIDER_ID}) to a
* Credentials API account type (such as {@link IdentityProviders#GOOGLE}).
*/
public static String providerIdToAccountType(@AuthUI.SupportedProvider @NonNull String providerId) {
switch (providerId) {
case GoogleAuthProvider.PROVIDER_ID:
return IdentityProviders.GOOGLE;
case FacebookAuthProvider.PROVIDER_ID:
return IdentityProviders.FACEBOOK;
case TwitterAuthProvider.PROVIDER_ID:
return IdentityProviders.TWITTER;
case PhoneAuthProvider.PROVIDER_ID:
return PHONE_IDENTITY;
// The account type for email/password creds is null
case EmailAuthProvider.PROVIDER_ID:
default:
return null;
}
}
示例4: testVerifyPhoneNumberNoMsgException_showsAlertDialog
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
@Test
@Config(shadows = {AuthHelperShadow.class})
public void testVerifyPhoneNumberNoMsgException_showsAlertDialog() {
reset(AuthHelperShadow.getPhoneAuthProvider());
mActivity.verifyPhoneNumber(PHONE, false);
verify(AuthHelperShadow.getPhoneAuthProvider()).verifyPhoneNumber(
eq(PHONE),
eq(AUTO_RETRIEVAL_TIMEOUT_MILLIS),
eq(TimeUnit.MILLISECONDS),
eq(mActivity),
callbacksArgumentCaptor.capture(),
(PhoneAuthProvider.ForceResendingToken) isNull());
PhoneAuthProvider.OnVerificationStateChangedCallbacks onVerificationStateChangedCallbacks
= callbacksArgumentCaptor.getValue();
onVerificationStateChangedCallbacks.onVerificationFailed(
new FirebaseAuthException("some_code", "custom_message"));
assertTrue(mActivity.getAlertDialog().isShowing());
assertEquals(FirebaseAuthError.ERROR_UNKNOWN.getDescription(), getAlertDialogMessage());
}
示例5: testAutoVerify
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
@Test
@Config(shadows = {AuthHelperShadow.class})
public void testAutoVerify() {
reset(AuthHelperShadow.getPhoneAuthProvider());
reset(AuthHelperShadow.getSaveSmartLockInstance(null));
reset(AuthHelperShadow.getFirebaseAuth());
when(AuthHelperShadow.getCurrentUser().getPhoneNumber()).thenReturn(PHONE);
when(AuthHelperShadow.getCurrentUser().getEmail()).thenReturn(null);
when(AuthHelperShadow.getFirebaseAuth().signInWithCredential(any(AuthCredential.class)))
.thenReturn(new AutoCompleteTask<>(FakeAuthResult.INSTANCE, true, null));
mActivity.verifyPhoneNumber(PHONE, false);
verify(AuthHelperShadow.getPhoneAuthProvider()).verifyPhoneNumber(
eq(PHONE),
eq(AUTO_RETRIEVAL_TIMEOUT_MILLIS),
eq(TimeUnit.MILLISECONDS),
eq(mActivity),
callbacksArgumentCaptor.capture(),
(PhoneAuthProvider.ForceResendingToken) isNull());
PhoneAuthProvider.OnVerificationStateChangedCallbacks onVerificationStateChangedCallbacks
= callbacksArgumentCaptor.getValue();
onVerificationStateChangedCallbacks.onVerificationCompleted(credential);
verify(AuthHelperShadow.getFirebaseAuth()).signInWithCredential(any(AuthCredential.class));
}
示例6: testSMSAutoRetrieval
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
@Test
@Config(shadows = {AuthHelperShadow.class})
public void testSMSAutoRetrieval() {
reset(AuthHelperShadow.getPhoneAuthProvider());
reset(AuthHelperShadow.getSaveSmartLockInstance(null));
when(credential.getSmsCode()).thenReturn("123456");
when(AuthHelperShadow.getCurrentUser().getPhoneNumber()).thenReturn(PHONE);
when(AuthHelperShadow.getCurrentUser().getEmail()).thenReturn(null);
when(AuthHelperShadow.getFirebaseAuth().signInWithCredential(any(AuthCredential.class)))
.thenReturn(new AutoCompleteTask<>(FakeAuthResult.INSTANCE, true, null));
PhoneAuthProvider.OnVerificationStateChangedCallbacks callbacks =
testSendConfirmationCode();
callbacks.onVerificationCompleted(credential);
SpacedEditText mConfirmationCodeEditText = mActivity.findViewById(R.id.confirmation_code);
//verify confirmation code set
assertEquals("1 2 3 4 5 6", mConfirmationCodeEditText.getText().toString());
//verify credential saves
verify(AuthHelperShadow.getFirebaseAuth()).signInWithCredential(credential);
}
示例7: pluginInitialize
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
@Override
protected void pluginInitialize() {
Log.d(TAG, "Starting Firebase Authentication plugin");
this.firebaseAuth = FirebaseAuth.getInstance();
this.phoneAuthProvider = PhoneAuthProvider.getInstance();
}
开发者ID:chemerisuk,项目名称:cordova-plugin-firebase-authentication,代码行数:8,代码来源:FirebaseAuthenticationPlugin.java
示例8: signInWithVerificationId
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void signInWithVerificationId(final String verificationId, final String code, final CallbackContext callbackContext) {
final PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
this.signinCallback = callbackContext;
cordova.getThreadPool().execute(new Runnable() {
@Override
public void run() {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user == null) {
firebaseAuth.signInWithCredential(credential)
.addOnCompleteListener(cordova.getActivity(), FirebaseAuthenticationPlugin.this);
} else {
user.updatePhoneNumber(credential)
.addOnCompleteListener(cordova.getActivity(), new OnCompleteListener<Void>() {
@Override
public void onComplete(Task<Void> task) {
if (task.isSuccessful()) {
callbackContext.success(getProfileData(firebaseAuth.getCurrentUser()));
} else {
callbackContext.error(task.getException().getMessage());
}
}
});
}
}
});
}
开发者ID:chemerisuk,项目名称:cordova-plugin-firebase-authentication,代码行数:30,代码来源:FirebaseAuthenticationPlugin.java
示例9: verifyPhoneNumber
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void verifyPhoneNumber(final String phoneNumber, final CallbackContext callbackContext) {
cordova.getThreadPool().execute(new Runnable() {
@Override
public void run() {
phoneAuthProvider.verifyPhoneNumber(phoneNumber, 0, MILLISECONDS, cordova.getActivity(),
new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user == null) {
firebaseAuth.signInWithCredential(credential);
} else {
user.updatePhoneNumber(credential);
}
callbackContext.success("");
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
callbackContext.success(verificationId);
}
@Override
public void onVerificationFailed(FirebaseException e) {
callbackContext.error(e.getMessage());
}
}
);
}
});
}
开发者ID:chemerisuk,项目名称:cordova-plugin-firebase-authentication,代码行数:33,代码来源:FirebaseAuthenticationPlugin.java
示例10: 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
}
示例11: startPhoneNumberVerification
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void startPhoneNumberVerification(String phoneNumber) {
// [START start_phone_auth]
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
120, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
// [END start_phone_auth]
mVerificationInProgress = true;
}
示例12: verify
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void verify(View v) {
if (verificationCodeEditext.length() == 0) {
Snackbar.make(v, R.string.insertcode, Snackbar.LENGTH_LONG)
.show();
return;
}
String code = verificationCodeEditext.getText().toString();
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
signIn(v, credential);
}
示例13: verifyPhoneNumber
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void verifyPhoneNumber(final String phoneNumber, final long timeout, final CallbackContext callbackContext) {
cordova.getThreadPool().execute(new Runnable() {
@Override
public void run() {
phoneAuthProvider.verifyPhoneNumber(phoneNumber, timeout, MILLISECONDS, cordova.getActivity(),
new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential credential) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user == null) {
firebaseAuth.signInWithCredential(credential);
} else {
user.updatePhoneNumber(credential);
}
}
@Override
public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
callbackContext.success(verificationId);
}
@Override
public void onVerificationFailed(FirebaseException e) {
callbackContext.error(e.getMessage());
}
}
);
}
});
}
开发者ID:kanodeveloper,项目名称:cordova-plugin-firebase-performance-ka,代码行数:31,代码来源:FirebaseAuthenticationPlugin.java
示例14: startPhoneNumberVerification
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void startPhoneNumberVerification(String phoneNumber) {
// [START start_phone_auth]
PhoneAuthProvider.getInstance().verifyPhoneNumber(
phoneNumber, // Phone number to verify
60, // Timeout duration
TimeUnit.SECONDS, // Unit of timeout
this, // Activity (for callback binding)
mCallbacks); // OnVerificationStateChangedCallbacks
// [END start_phone_auth]
mVerificationInProgress = true;
}
示例15: submitConfirmationCode
import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
public void submitConfirmationCode(@NonNull String confirmationCode) {
if (TextUtils.isEmpty(mVerificationId) || TextUtils.isEmpty(confirmationCode)) {
// This situation should never happen except in the case of an extreme race
// condition, so we will just ignore the submission.
// See: https://github.com/firebase/FirebaseUI-Android/issues/922
Log.w(PHONE_VERIFICATION_LOG_TAG,
String.format("submitConfirmationCode: mVerificationId is %s ; " +
"confirmationCode is %s", TextUtils.isEmpty(mVerificationId) ? "empty" : "not empty",
TextUtils.isEmpty(confirmationCode) ? "empty" : "not empty"));
return;
}
showLoadingDialog(getString(R.string.fui_verifying));
signIn(PhoneAuthProvider.getCredential(mVerificationId, confirmationCode));
}