IOS development-App integrated text message Verification Code

Source: Internet
Author: User

IOS development-App integrated text message Verification Code

Whether on a webpage or on a client, we often perform text message or email verification when registering. This is a good security mechanism. For user experience, it is more convenient to use email or text message for verification on PC web pages, and text message for verification on mobile phones. This blog will implement the SMS verification code function in iOS apps.

You can try development. During the debugging process, we must note that we can only send five verification messages (within 12 hours) to the same number ). You cannot receive the verification text message when the quota is exceeded. This is determined by the telecom operator and is also a security method to prevent spam messages. Imagine if you keep sending verification codes to a number, will it become a spam message? So there is a limit on the quantity. This restriction makes debugging programs more difficult, which means that we can only run five programs in a day .... I have to think about it every time I debug the program. Do I want to send it? For this reason, I tested this simple function for 2 days... Who gave me only one number?

The specific implementation steps are as follows:

(1) log on to the mob mobile developer service platform, register and log on, download the SMS Verification Code SDK, SMS for iOS, and drag it directly to the project. There is also an example demo, which is quite good and supports global sending.

(2) Go to the background and create an application. Obtain the App Key and App Secret, which will be used in the project. In this way, we have a server.

.

 

(3) Send the verification code. You only need to send the country code + mobile phone number to the server. Generally, you can receive the verification code within 5 seconds. The Country Code in China is 86. If your App needs to be released abroad, you need to configure it accordingly. In the demo that comes with it, the country is selected.

 

[SMSSDK getVerificationCodeByMethod: SMSGetCodeMethodSMS phoneNumber: @ 18888888888 zone: @ 86 customIdentifier: nil result: ^ (NSError * error) {if (! Error) {// callback for successful sending of the Verification Code;} else {// callback for failed sending of the Verification Code; if you enter an incorrect mobile phone number or any number, will be called back;}];


 

(4) Verify that the verification code is correct. As long as you send a mobile phone number to the server and the verification code you just received, the server will perform a matching verification and then perform the corresponding callback.

Note: 1) a verification code can only be verified once. Once the verification fails for the first time, the verification will not succeed even if the correct verification code is entered for the second time.

2) After receiving the verification code, the verification code is valid only within 60 s. If the verification code is correct for more than 60 s, the verification fails.

The implementation code is as follows:

 

[SMSSDK commitVerificationCode: 1234 (Verification Code) phoneNumber: 18888888888 zone: @ 86 result: ^ (NSError * error) {if (! Error) {// callback after successful verification;} // if (); else {// callback after failed verification;}];

Conclusion: The verification code can be used for registration or password retrieval to verify your identity. How to extend the verification code function depends on your idea.

 

 

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.