iOS use skills-SMS, language Verification Code acquisition and verification summary

Source: Internet
Author: User

Recently have learned a small skill, here to summarize, share to everyone, communicate with each other.

The first is the general steps:

    1. Register on the Mob website and add the app for SMS verification
    2. Importing frames using Cocoapods
podfile File:Platform:ios, "6.0" target ' SMS verification ' # Mob product Public Library
Pod ' MOBFOUNDATION_IDFA '
# smssdk must be pod ' smssdk ' End 

3. Register the application in Appdelegate Appkey

4. Get the Verification code

5. Submit the Verification Code

6. Note: Fit to remember to turn on HTTPS

1. In AppDelegate the

//   Register Appkey  [smssdk registerapp:@ "14810905c09b0" withsecret:@ "  fbea3e77174d8c9da1d0839b1f0bdc82"];

Such as:

2. SMS and language can be implemented in one simple way

/** * SMS Verification Code*/-(ibaction) messageverify {//Verify that the phone number is legitimateNSString *phonenumber =Self.phoneNumber.text; if(![PhoneNumber Isphone]) {NSLog (@"you entered the phone number incorrectly"); return; } self.savephonenumber=PhoneNumber; //Get SMS Verification Code[Smssdk getverificationcodebymethod:smsgetcodemethodsms Phonenumber:phonenumber Zone:@" the"Customidentifier:nil result:^ (Nserror *error) {        if(Error) {NSLog (@"failed to get verification code:%@", error); }Else{NSLog (@"Get Verification Code Success"); }    }];}/** * Language Verification Code*/-(ibaction) voiceverify {//Verify that the phone number is legitimateNSString *phonenumber =Self.phoneNumber.text; if(![PhoneNumber Isphone]) {NSLog (@"you entered the phone number incorrectly"); return; } self.savephonenumber=PhoneNumber; //get voice Verification code[Smssdk getverificationcodebymethod:smsgetcodemethodvoice Phonenumber:phonenumber Zone:@" the"Customidentifier:nil result:^ (Nserror *error) {        if(Error) {NSLog (@"failed to get verification code:%@", error); }Else{NSLog (@"Get Verification Code Success"); }    }];}/** * Verify*/-(ibaction) Verifyresult {//Verify that the verification code is legitimateNSString *verifycode =Self.verifyLabel.text; if(Verifycode.length! =4) {NSLog (@"Verify input Errors"); return; }    //Submit Verification Code[Smssdk Commitverificationcode:verifycode PhoneNumber:self.savePhoneNumber Zone:@" the"result:^ (Nserror *error) {        if(!error) {NSLog (@"Validation Successful"); }Else{NSLog (@"error message:%@", error); }    }];}

The example above is the use of the Mob default text message format, can also be customized, according to their own situation to choose.

There are some other modifications that you can use to read the SDK documentation on the mob to integrate the form you need.

iOS use skills-SMS, language Verification Code acquisition and verification summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.