Skip to content

只需要三行代码就能发送验证码的库

Notifications You must be signed in to change notification settings

adonis-lsh/SMSDemo

Repository files navigation

只需三行代码就能实现短信的验证(ShareSDK的简单封装)

记得关闭ShareSDK后台的的智能验证

先上图:

使用方法

  • 在项目中的build.gradle下面加上
		 compile 'com.lsh.smsverification:smsverification:1.0.0'
  • 初始化短信
		 new SmsAPI().initSDK(getApplicationContext(), appkey, appSecret)
  • 发送短信的时候调用:
		 sendVerifyPhoneNum(mPhoneNumber, new SmsAPI.Send_State() {
                            @Override
                            public void sendPhoneResult(int stateCode, String des) {
                                if (stateCode == SmsAPI.SUCCESS_CODE) {
                                    Log.e(stateCode + "", des);
                                }
                            }
                        });
  • 发送验证码调用
		 sendVerificationCode(mVerCode, new SmsAPI.Verification_State() {
            @Override
            public void sendVerificationCodeResult(int stateCode, String des) {
                if (stateCode == SmsAPI.SUCCESS_CODE) {
                    Log.e(stateCode + "", des);
                    Toast.makeText(MainActivity.this, "登录成功", Toast.LENGTH_SHORT).show();
                }
            }
        })
  • 最后记得取消调用
		    @Override
    		protected void onDestroy() {
        			super.onDestroy();
        		mSmsAPI.cancelCall();
    		}

对于短信的智能验证后面会陆续加上去,对于常见错误码请看ShareSdk,也可以看demo中的

About

只需要三行代码就能发送验证码的库

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages