SMS Verification
Now a lot of SMS verification platform, we are more commonly used mobile developer service Platform
Integrate with SMS verification documentation
1. Find The integrated development documentation for IOS SMS verification
2. Download the SDK and Demo directory structure
3. run Demo
4. Write your own test Demo to follow the documentation step-by -step .
1. Create a project
2. import svprogresshud and sms_sdk
3. add dependent library files
- Necessary:
Libicucore.dylib
- Libz.dylib
- Messageui.framework
- Javascriptcore.framework
- Libstdc++.dylib
- Optional:
Addressbook.framework (Address Book function required)
- Addressbookui.framework (Address Book function required)
3. Add in the info.plist file , set the use of unsafe network
Nsapptransportsecurity Type Dictionary
- Nsallowsarbitraryloads = YES Type BooL
4. Add initialization code
- Add in Appdelegate
#import <SMS_SDK/SMSSDK.h>
And
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {
- Sign up for SMS verification
- [Smssdk Registerapp:appkey Withsecret:appsecret];
- return YES;
- }
Acquisition of AppKey and Appsecret:
- Register as a mob developer on the mob website;
- Create a new app in the app management background.
- Create a button to get a CAPTCHA, or call a method to get a verification code in a button event of an existing interface
-(ibaction) Verifyvoice {
- NSString *phonenumber = Self.phoneNumTextField.text;
- Get Voice Verification Code
- [Smssdk getverificationcodebymethod:smsgetcodemethodvoice phonenumber:phonenumber zone:@ "CustomIdentifier:nil" result:^ (Nserror *error) {
- Note that the area code (zone) and mobile phone number (PhoneNumber) do not add "+" number, some developers like to write, @ "+86", this is the wrong way of writing
- if (Error) {
- NSLog (@ "%@", error);
- [Svprogresshud showerrorwithstatus:@ "Please re-obtain the verification Code"];
- }
- }];
- }
- Create a button that submits a verification code, or invoke a method to submit a verification code in a button event of an existing interface
Verify
- [Smssdk commitVerificationCode:self.verifyTextField.text phoneNumber:self.phoneNumTextField.text zone:@ "The result" : ^ (Nserror *error) {
- if (Error) {
- NSLog (@ "%@", error);
- [Svprogresshud showerrorwithstatus:@ "validation failed!"];
- }else{
- [Svprogresshud showsuccesswithstatus:@ "verified success!"];
- }
- }];
- Note: Now carrier restrictions: The same number 12 hours to send no more than 5, 24 hours not more than 10
IOS SMS Authentication