• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PhoneAuthProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.firebase.auth.PhoneAuthProvider的典型用法代码示例。如果您正苦于以下问题:Java PhoneAuthProvider类的具体用法?Java PhoneAuthProvider怎么用?Java PhoneAuthProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PhoneAuthProvider类属于com.google.firebase.auth包,在下文中一共展示了PhoneAuthProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
                // ...
            }
        }
    };
}
 
开发者ID:kcj8855,项目名称:Ae4Team,代码行数:24,代码来源:ChangePhoneNumberActivity.java


示例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;
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:21,代码来源:ProviderUtils.java


示例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());
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:23,代码来源:PhoneActivityTest.java


示例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));
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:27,代码来源:PhoneActivityTest.java


示例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);
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:23,代码来源:PhoneActivityTest.java


示例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
}
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:11,代码来源:RegisterPhoneActivity.java


示例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;
}
 
开发者ID:kcj8855,项目名称:Ae4Team,代码行数:12,代码来源:ChangePhoneNumberActivity.java


示例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);
    }
 
开发者ID:shiburagi,项目名称:SignUpPhone,代码行数:12,代码来源:LoginActivity.java


示例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;
}
 
开发者ID:firebase,项目名称:quickstart-android,代码行数:13,代码来源:PhoneAuthActivity.java


示例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));
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:16,代码来源:PhoneActivity.java


示例16: sendCode

import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void sendCode(String phoneNumber, boolean forceResend) {
    mPhoneNumber = phoneNumber;
    mVerificationState = VerificationState.VERIFICATION_STARTED;

    getAuthHelper().getPhoneAuthProvider().verifyPhoneNumber(
            phoneNumber,
            AUTO_RETRIEVAL_TIMEOUT_MILLIS,
            TimeUnit.MILLISECONDS,
            this,
            new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
                @Override
                public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential) {
                    if (!mIsDestroyed) {
                        PhoneActivity.this.onVerificationSuccess(phoneAuthCredential);
                    }
                }

                @Override
                public void onVerificationFailed(FirebaseException ex) {
                    if (!mIsDestroyed) {
                        PhoneActivity.this.onVerificationFailed(ex);
                    }
                }

                @Override
                public void onCodeSent(@NonNull String verificationId,
                                       @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) {
                    mVerificationId = verificationId;
                    mForceResendingToken = forceResendingToken;
                    if (!mIsDestroyed) {
                        PhoneActivity.this.onCodeSent();
                    }
                }
            },
            forceResend ? mForceResendingToken : null);
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:37,代码来源:PhoneActivity.java


示例17: finish

import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void finish(FirebaseUser user) {
    IdpResponse response = new IdpResponse.Builder(
            new User.Builder(PhoneAuthProvider.PROVIDER_ID, null)
                    .setPhoneNumber(user.getPhoneNumber())
                    .build())
            .build();
    finish(RESULT_OK, response.toIntent());
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:9,代码来源:PhoneActivity.java


示例18: accountTypeToProviderId

import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
@AuthUI.SupportedProvider
public static String accountTypeToProviderId(@NonNull String accountType) {
    switch (accountType) {
        case IdentityProviders.GOOGLE:
            return GoogleAuthProvider.PROVIDER_ID;
        case IdentityProviders.FACEBOOK:
            return FacebookAuthProvider.PROVIDER_ID;
        case IdentityProviders.TWITTER:
            return TwitterAuthProvider.PROVIDER_ID;
        case PHONE_IDENTITY:
            return PhoneAuthProvider.PROVIDER_ID;
        default:
            return null;
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:16,代码来源:ProviderUtils.java


示例19: startAuthMethodChoice

import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
private void startAuthMethodChoice() {
    FlowParameters flowParams = getFlowParams();
    List<AuthUI.IdpConfig> idpConfigs = flowParams.providerInfo;

    // If there is only one provider selected, launch the flow directly
    if (idpConfigs.size() == 1) {
        AuthUI.IdpConfig firstIdpConfig = idpConfigs.get(0);
        String firstProvider = firstIdpConfig.getProviderId();
        switch (firstProvider) {
            case EmailAuthProvider.PROVIDER_ID:
                // Go directly to email flow
                startActivityForResult(
                        EmailActivity.createIntent(getContext(), flowParams),
                        RC_EMAIL_FLOW);
                break;
            case PhoneAuthProvider.PROVIDER_ID:
                // Go directly to phone flow
                Bundle params = firstIdpConfig.getParams();
                Intent phoneActivityIntent = PhoneActivity
                        .createIntent(getContext(), flowParams, params);
                startActivityForResult(
                        phoneActivityIntent,
                        RC_PHONE_FLOW);
                break;
            default:
                // Launch IDP flow
                redirectToIdpSignIn(null, ProviderUtils.providerIdToAccountType(firstProvider));
                break;
        }
    } else {
        startActivityForResult(
                AuthMethodPickerActivity.createIntent(
                        getContext(),
                        flowParams),
                RC_AUTH_METHOD_PICKER);
    }
    getDialogHolder().dismissDialog();
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:39,代码来源:SignInDelegate.java


示例20: testVerifyPhoneNumberInvalidPhoneException_showsInlineError

import com.google.firebase.auth.PhoneAuthProvider; //导入依赖的package包/类
@Test
@Config(shadows = {AuthHelperShadow.class})
public void testVerifyPhoneNumberInvalidPhoneException_showsInlineError() {
    reset(AuthHelperShadow.getPhoneAuthProvider());

    mActivity.verifyPhoneNumber(PHONE, false);
    //was dialog displayed
    assertEquals(
            mActivity.getString(R.string.fui_verifying),
            mActivity.mProgressDialog.mMessageView.getText());

    //was upstream method invoked
    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(
                    FirebaseAuthError.ERROR_INVALID_PHONE_NUMBER.toString(),
                    "any_message"));

    //was error displayed
    assertEquals(mPhoneLayout.getError(), mActivity.getString(R.string.fui_invalid_phone_number));
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:31,代码来源:PhoneActivityTest.java



注:本文中的com.google.firebase.auth.PhoneAuthProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CLContext类代码示例发布时间:2022-05-23
下一篇:
Java MapsTo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap