Description of JSMS iOS SDK API

Obtain SMS Verification Code

  1. + (void)getVerificationCodeWithPhoneNumber:(NSString * _Nonnull)number
  2. andTemplateID:(NSString * _Nonnull)templateID
  3. completionHandler:(JSMSCompletionHandler _Nonnull)handler;

Interface Description

Get interface of SMS verification code: Create a button to get the SMS verification code, or call the SMS verification code in the button event of the existing interface.

Parameter Description

  • number: Mobile number

  • templateID: SMS template ID

  • handler: The callback of request or request failure

Call Example

  1. //点击获取短信验证码
  2. - (IBAction)sendSmsAuthCode:(id)sender {
  3. [JSMSSDK getVerificationCodeWithPhoneNumber:@"152xxxxxxxx" andTemplateID:@"1" completionHandler:^(id resultObject, NSError *error) {
  4. if (!error) {
  5. NSLog(@"Get verification code success!");
  6. }else{
  7. NSLog(@"Get verification code failure!");
  8. NSLog(@"%@",error);
  9. }
  10. }];
  11. }

Get Voice Verification Code

Interface to get voice verification code is added in Version 1.2.0.

  1. + (void)getVoiceVerificationCodeWithPhoneNumber:(NSString * _Nonnull)number
  2. completionHandler:(JSMSCompletionHandler _Nonnull)handler;

Interface Description

Interface for obtaining voice verification code: Create button to get voice verification code, or call the method to get voice verification code in button event of existing interface

Parameter Description

  • number: Mobile number

  • handler: The callback of request or request failure

Call Example

  1. //点击获取语音验证码
  2. - (IBAction)sendVoiceAuthCode:(id)sender {
  3. [JSMSSDK getVoiceVerificationCodeWithPhoneNumber:@"152xxxxxxxx" completionHandler:^(id resultObject, NSError *error) {
  4. if (!error) {
  5. NSLog(@"Get voice verification code success!");
  6. }else{
  7. NSLog(@"Get voice verification code failure!");
  8. NSLog(@"%@",error);
  9. }
  10. }];
  11. }

Get Voice Verification Code (broadcast language can be set)

Interface to get voice verification code is added in Version 1.4.0, which can set type of broadcast language.

  1. + (void)getVoiceVerificationCodeWithPhoneNumber:(NSString * _Nonnull)number
  2. languageOptions:(JSMSLanguageOptions)options
  3. completionHandler:(JSMSCompletionHandler _Nonnull)handler;

Interface Description

Interface for obtaining voice verification code: Create button to get voice verification code, or call the method to get voice verification code in button event of existing interface

Parameter Description

  • number: Mobile number

  • options: Broadcast language. When the parameter is invalid, default language is Chinese

  • handler: The callback of request or request failure

Call Example

  1. //点击获取语音验证码
  2. - (IBAction)sendVoiceAuthCode:(id)sender {
  3. [JSMSSDK getVoiceVerificationCodeWithPhoneNumber:@"152xxxxxxxx"
  4. languageOptions:JSMSLanguage_zh_Hans
  5. completionHandler:^(id resultObject, NSError *error) {
  6. if (!error) {
  7. NSLog(@"Get voice verification code success!");
  8. }else{
  9. NSLog(@"Get voice verification code failure!");
  10. NSLog(@"%@",error);
  11. }
  12. }];
  13. }

Verify Verification Code

  1. + (void)commitWithPhoneNumber:(NSString * _Nonnull)number
  2. verificationCode:(NSString * _Nonnull)vCode
  3. completionHandler:(JSMSCompletionHandler _Nonnull)handler;

Interface Description

Verify verification code: Create a button to submit a verification code, or call a verification code in a button event of an existing interface.

Parameter Description

  • number: Mobile number

  • vCode: SMS verification code

  • handler: The callback of request or request failure

Call Example

  1. //验证验证码
  2. [JSMSSDK commitWithPhoneNumber:@"152xxxxxxxx" verificationCode:@"123456" completionHandler:^(id resultObject, NSError *error) {
  3. if (!error) {
  4. NSLog(@"Commit verification vode success!");
  5. }else{
  6. NSLog(@"%@",error);
  7. NSLog(@"Commit verification code failure!");
  8. }
  9. }];

Set the Interval of Verification Code Request

Set the interface for obtaining the interval of verification code request is added in Version 1.2.0.

  1. + (void)setMinimumTimeInterval:(NSTimeInterval)seconds;

Interface Description

Set the interface for obtaining the interval of verification code request: You can only send the request to obtain the verification code within the set interval once. If you do not call this interface, default interval of sdk is 30s

Parameter Description

  • seconds: Interval

Call Example

  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  2. [JSMSSDK setMinimumTimeInterval:60];
  3. return YES;
  4. }

Description of Error Code

Error Code Description of Error Code Remarks
2993 Uuid error. Verification of verification code failed
2994 Parameter error
2996 Two requests within the minimum time interval
2997 The number changed. Please get the verification code first
2998 Network Error
2999 Other errors
3001 Request timed out
4204 Invalid mobile number
4001 Body is empty
4002 Invalid AppKey
4003 Invalid source
4004 Decryption of body failed
4005 Decryption of aes key failed
4006 Timestamp conversion failed
4007 Format of body is incorrect
4008 Invalid timestamp
4009 No SMS verification permission
4011 Send overclocking There is no limit for the same mobile phone number getting verification code every day. The notification verification code with same content is 3 pieces in 10 minutes, and there are no restrictions on different contents. The marketing category is also 3 in 10 minutes.
4012 Api does not exist
4013 Template does not exist
4014 Extra is empty
4015 Incorrect verification code
4016 No margin
4017 Verification code timeout
4018 Verification code has been verified
5000 Server error