美文网首页
Mob免费短信验证

Mob免费短信验证

作者: 张三儿 | 来源:发表于2017-03-21 17:23 被阅读183次

<h1>1.导入SDK以及类库</h1>###

libz.dylib
libicucore.dylib
MessageUI.framework
JavaScriptCore.framework
libstdc++.dylib

<h1>2.AppKey</h1>###

//appdelegate里初始化应用,appKey和appSecret从后台申请得
    [SMSSDK registerApp:APPKEY withSecret:APPSECERT];

<h1>3.点击获取验证码按钮之后</h1>###

<ol>
<li>先判断手机号</li>
<li>调用Mod接口</li>
<li>启动定时器</li>
</ol>

-(void)getValidCode:(UIButton *)sender
{
//将输入的手机号进行转换成NSScanner对象
    NSScanner *scan = [NSScanner scannerWithString:_phoneTextFiled.text];
    int val;
//扫描 手机号是否是数字类型
    BOOL PureInt = [scan scanInt:&val]&&[scan isAtEnd];

    if (!PureInt || _phoneTextFiled.text.length !=11)
    {
        [_phoneTextFiled shake];
    }
    else
    {
        
        
        /**
         *  @from                    v1.1.1
         *  @brief                   获取验证码(Get verification code)
         *
         *  @param method            获取验证码的方法(The method of getting verificationCode)
         *  @param phoneNumber       电话号码(The phone number)
         *  @param zone              区域号,不要加"+"号(Area code)
         *  @param customIdentifier  自定义短信模板标识 该标识需从官网http://www.mob.com上申请,审核通过后获得。(Custom model of SMS.  The identifier can get it  from http://www.mob.com  when the application had approved)
         *  @param result            请求结果回调(Results of the request)
         */
        
        [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:_phoneTextFiled.text
                                       zone:@"86"
                           customIdentifier:nil
                                     result:^(NSError *error){
                                         if (!error) {
                                             NSLog(@"获取验证码成功");
                                         } else {
                                             NSLog(@"错误信息:%@",error);
                                         }}];

        
        _oUserPhoneNum =_phoneTextFiled.text;
        //__weak MMZCHMViewController *weakSelf = self;
        sender.userInteractionEnabled = YES;
        self.timeCount = 60;
        self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(reduceTime:) userInfo:sender repeats:YES];
        
    }
}

Timer循环程序

-(void)reduceTime:(NSTimer *)codeTimer
{
    self.timeCount--;
    if (self.timeCount == 0) {
        [_yzButton setTitle:@"重新获取验证码" forState:UIControlStateNormal];
        [_yzButton setTitleColor:[UIColor colorWithRed:248/255.0f green:144/255.0f blue:34/255.0f alpha:1] forState:UIControlStateNormal];
        UIButton *info = codeTimer.userInfo;
        info.enabled = YES;
        _yzButton.userInteractionEnabled = YES;
        [self.timer invalidate];
    } else {
        NSString *str = [NSString stringWithFormat:@"%lu秒后重新获取", self.timeCount];
        [_yzButton setTitle:str forState:UIControlStateNormal];
        _yzButton.userInteractionEnabled = NO;
        
    }
}

<h1>4.输入验证码,点击下一步</h1>###

-(void)next:(UIButton *)button
{
    
    [SMSSDK commitVerificationCode:_pwdTextFiled.text phoneNumber:_phoneTextFiled.text zone:@"86" result:^(SMSSDKUserInfo *userInfo, NSError *error) {

            if (!error)
            {
                //页面跳转
                
                NSLog(@"成功");
               
            }
            else
            {
                NSLog(@"错误信息:%@",error);
                
                [_pwdTextFiled shake];
                [_phoneTextFiled shake];
                UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请输入正确的手机号码和验证码" message:nil preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil];
                [alert addAction:action];
                [self presentViewController:alert animated:YES completion:nil];
            }
    }];
    
}

相关文章

  • Mob免费短信验证

    1.导入SDK以及类库

    ### libz.dyliblibicucore.dylibMessage...

  • 使用Mob进行短信验证码发送

    首先,很多第三方短信验证码都可以,为什么我要选择mob的呢?因为mob的短信验证码是完全免费mob的官网:http...

  • 短信验证MOb

    首先,到mob开发平台 http://www.mob.com/#/ ,注册账 然后,点击SDK下载,点击SMS F...

  • 短信验证(Mob)

    在做项目的时候经常会用到短信验证方面的功能,本章就介绍一下Mob平台的短信验证:首先,[Mob] http://w...

  • 短信验证(Mob)

    在做项目的时候经常会用到短信验证方面的功能,本章就介绍一下Mob平台的短信验证: 首先,[Mob]http://w...

  • 【Android】Mob短信验证

    在用户注册的时候,短信验证码想必是不可缺少的一个环节,这里给大家介绍一个免费的第三方短信验证SDK——Mob 想要...

  • 一些Android开发中常用的第三方sdk

    1、Share SDK官网 www.mob.com。免费集成注册短信验证码,友好的分享功能。 2、环信sdk。主要...

  • 短信验证

    1.介绍 通过mob平台来做短信验证。到mob平台进行注册,下载 SMS For iOS 即可。根据mob平台提供...

  • Android Mob短信验证

    首先到Mon(http://www.mob.com/)官网上注册登录,添加一个SMSSDK应用,获取App Key...

  • 第三方平台

    Mob Mob官网 - 中国最大的移动开发者服务平台常用的是第三方登陆分享及短信验证(完全免费) 友盟 全球领先的...

网友评论

      本文标题:Mob免费短信验证

      本文链接:https://www.haomeiwen.com/subject/kdugnttx.html