SMS Retriever API的依赖关系

Sas*_*iha 21 android google-play-services build.gradle

我正在尝试实现SMS Retriever API,但我无法找到类似的类SmsRetrieverClient.我无法导入它们.

请参阅以下示例代码:

 SmsRetrieverClient client = SmsRetriever.getClient(context);
 Task<Void> task = client.startSmsRetriever();
 task.addOnSuccessListener(new OnSuccessListener<Void>() {});
Run Code Online (Sandbox Code Playgroud)

我添加了以下依赖项,之后我可以引用这些类:

compile 'com.google.android.gms:play-services:11.0.2'
Run Code Online (Sandbox Code Playgroud)
  1. 但由于这包括所有服务API,我想知道特定于的依赖项 SMS Retriever API

    我已经提到了这个文档的所有依赖并添加了以下,但它没有用.

    com.google.android.gms:play-services-auth:11.0.2
    com.google.android.gms:play-services-identity:11.0.2
    
    Run Code Online (Sandbox Code Playgroud)
  2. 另外,是否需要11.xx版本?

not*_*one 31

尝试添加以下依赖项:

implementation "com.google.android.gms:play-services-auth-api-phone:$playServicesVersion"
Run Code Online (Sandbox Code Playgroud)

替换$playServicesVersion为您正在使用的播放服务版本.

  • `编译'com.google.android.gms:play-services-base:11.0.2'编译'com.google.android.gms:play-services-identity:11.0.2'编译'com.google.android.gms :play-services-auth:11.0.2' 编译 'com.google.android.gms:play-services-auth-api-phone:11.0.2'` (5认同)