如何将GoogleAPIClient与SMSRetriver API android一起使用

问题描述 投票:2回答:1

我正在尝试实施SMS检索器API进行SMS验证。文档中提到的官方方式说,要结合使用GoogleApiClient和HintRequest来从设备中检索手机号码

HintRequest hintRequest = new HintRequest.Builder()
            .setPhoneNumberIdentifierSupported(true)
            .build();

PendingIntent intent = Auth.CredentialsApi.getHintPickerIntent(
            googleApiClient, hintRequest);
try {
    startIntentSenderForResult(intent.getIntentSender(),
                RESOLVE_HINT, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
    e.printStackTrace();
}

但是GoogleAPIClient已弃用,并由GoogleSignInClient代替。我尝试使用GoogleSignInClient,但getHintPickerIntent不接受。即使弃用旧版本的API还是安全的,还是可以通过SMSRetriver API使用旧版本的API?

android firebase google-api-client googlesigninapi smsretriverapi
1个回答
0
投票
        GoogleApiClient googleApiClient = new GoogleApiClient.Builder(requireContext())
            .addApi(Auth.CREDENTIALS_API).build();
© www.soinside.com 2019 - 2024. All rights reserved.