Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

leancloud/android-sms-demo

Repository files navigation

LeanCloud 中的短信验证示例

见文档 短信验证码服务

LeanCloud 站点下载地址

安装

导入 LeanCloud SDK, 然后在 android-sms-demo/app/src/main/java/com/avos/sms/App.java 里把 xxx 换成你自己的 App ID 和 App Key。

public class App extends Application{
  public void onCreate() {
    // 请用你的 AppId,AppKey。并在管理台启用手机号码短信验证
    AVOSCloud.initialize(this, "xxx",
        "xxx");
  }
}

发送验证短信

AVOSCloud.requestSMSCode(phone, "应用名称", "操作名称", 10);  // 10 分钟内有效

判别验证码

 AVOSCloud.verifySMSCodeInBackground(code, phone, new AVMobilePhoneVerifyCallback() {
      @Override
      public void done(AVException e) {
        if(e==null){
          toast(R.string.verifySucceed);
        }else{
          e.printStackTrace();
          toast(R.string.verifyFailed);
        }
      }
    });

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages