Here the use of sms_sdk.framework (Mob official website to download) to do the SMS verification, the operation is very simple, to register their own account to get appkey then it is necessary to import some library files need to import the library has Security.framework Foundation.framework, Uikit.framework, Coregraphics.framework, Libicucore.dylib, Libz.lib, Addressbook.framework, Addressbookui.framework, Messageui.framework and Sms_sdk.framework
First, determine if the phone number is correct and set the limit time for SMS if ([_field.text length] = =) { [sms_sdk getverifycodebyphonenumber:_field.text andzone:@ "result:^" (enum Sms_getverifycoderesponsestate state) { if (1 = = state) { self.times =; Self.timer = [Nstimer scheduledtimerwithtimeinterval:1 target:self selector: @selector (buttonactionshow) UserInfo:nil Repeats:yes]; [Nstimer scheduledtimerwithtimeinterval:15 target:self selector: @selector (Xianzhi:) Userinfo:nil repeats:no]; } else { NSLog (@ "filed"); } }]; } else { Uialertview *aler = [[Uialertview alloc] Initwithtitle:nil message:@ "Input phone number is wrong" delegate:self cancelbuttontitle:nil otherbuttontitles:@ "OK", nil]; [Aler show]; }
Verify correct [sms_sdk commitVerifyCode:self.phone.text result:^ (enum sms_responsestate state) { if (state = = 1) { Uialertview *aler = [[Uialertview alloc] Initwithtitle:nil message:@ "Verify success" Delegate:self Cancelbuttontitle:nil otherbuttontitles:@ "OK", nil]; [Aler show]; } else { Uialertview *aler = [[Uialertview alloc] initwithtitle:nil message:@ "input captcha Error" delegate:self Cancelbuttontitle:nil otherbuttontitles:@ "OK", nil]; [Aler show]; } }];
Xianzhi Method--written here pinyin-(void) Xianzhi: (ID) sender{ [_button Setenabled:yes]; [_timer invalidate]; _timer = nil; [_button setalpha:1]; [_button settitle:@ "regain" forstate:uicontrolstatenormal]; }
Timer countdown self.times--; self.button.enabled = NO; [Self.button settitle:[nsstring stringwithformat:@ "%ld seconds", Self.times] forstate:uicontrolstatenormal];
SMS Verification of iOS development