JSMS iOS SDK API Description
Special note: the client SDK of Jiguang SMS is no longer updated or maintained. Developers should use the Rest API to complete business logic.
Get SMS Verification Code
API Description
Get SMS verification code API: create a button for getting an SMS verification code, or call the method for getting an SMS verification code in the button event of your existing page.
+ (void)getVerificationCodeWithPhoneNumber:(NSString * _Nonnull)number
andTemplateID:(NSString * _Nonnull)templateID
completionHandler:(JSMSCompletionHandler _Nonnull)handler;
Parameter Description
- number: mobile number
- templateID: SMS template ID
- handler: callback for request success or failure
Call Example
// Click to get SMS verification code
- (IBAction)sendSmsAuthCode:(id)sender {
[JSMSSDK getVerificationCodeWithPhoneNumber:@"152xxxxxxxx" andTemplateID:@"1" completionHandler:^(id resultObject, NSError *error) {
if (!error) {
NSLog(@"Get verification code success!");
}else{
NSLog(@"Get verification code failure!");
NSLog(@"%@",error);
}
}];
}
Get Voice Verification Code
API Description
Get voice verification code API: create a button for getting a voice verification code, or call the method for getting a voice verification code in the button event of your existing page.
Added in version 1.2.0: API for getting voice verification codes.
+ (void)getVoiceVerificationCodeWithPhoneNumber:(NSString * _Nonnull)number
completionHandler:(JSMSCompletionHandler _Nonnull)handler;
Parameter Description
- number: mobile number
- handler: callback for request success or failure
Call Example
// Click to get voice verification code
- (IBAction)sendVoiceAuthCode:(id)sender {
[JSMSSDK getVoiceVerificationCodeWithPhoneNumber:@"152xxxxxxxx" completionHandler:^(id resultObject, NSError *error) {
if (!error) {
NSLog(@"Get voice verification code success!");
}else{
NSLog(@"Get voice verification code failure!");
NSLog(@"%@",error);
}
}];
}
Get Voice Verification Code (Broadcast Language Configurable)
API Description
Get voice verification code API: create a button for getting a voice verification code, or call the method for getting a voice verification code in the button event of your existing page.
Added in version 1.4.0: get voice verification code, with configurable broadcast language type.
+ (void)getVoiceVerificationCodeWithPhoneNumber:(NSString * _Nonnull)number
languageOptions:(JSMSLanguageOptions)options
completionHandler:(JSMSCompletionHandler _Nonnull)handler;
Parameter Description
- number: mobile number
- options: broadcast language. If the parameter is invalid, Chinese broadcast is used by default.
- handler: callback for request success or failure
Call Example
// Click to get voice verification code
- (IBAction)sendVoiceAuthCode:(id)sender {
[JSMSSDK getVoiceVerificationCodeWithPhoneNumber:@"152xxxxxxxx"
languageOptions:JSMSLanguage_zh_Hans
completionHandler:^(id resultObject, NSError *error) {
if (!error) {
NSLog(@"Get voice verification code success!");
}else{
NSLog(@"Get voice verification code failure!");
NSLog(@"%@",error);
}
}];
}
Verify Verification Code
API Description
Verify verification code: create a button for submitting a verification code, or call the method for submitting a verification code in the button event of your existing page.
+ (void)commitWithPhoneNumber:(NSString * _Nonnull)number
verificationCode:(NSString * _Nonnull)vCode
completionHandler:(JSMSCompletionHandler _Nonnull)handler;
Parameter Description
- number: mobile number
- vCode: SMS verification code
- handler: callback for request success or failure
Call Example
// Verify verification code
[JSMSSDK commitWithPhoneNumber:@"152xxxxxxxx" verificationCode:@"123456" completionHandler:^(id resultObject, NSError *error) {
if (!error) {
NSLog(@"Commit verification vode success!");
}else{
NSLog(@"%@",error);
NSLog(@"Commit verification code failure!");
}
}];
Set Request Verification Code Time Interval
API Description
API for setting the request interval for getting verification codes: only one request to get a verification code can be sent within the configured time interval. If this API is not called, the SDK default interval is 30s.
Added in version 1.2.0: API for setting the request interval for getting verification codes.
+ (void)setMinimumTimeInterval:(NSTimeInterval)seconds;
Parameter Description
- seconds: time interval
Call Example
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[JSMSSDK setMinimumTimeInterval:60];
return YES;
}
Error Code Description
Error Code |
Error Code Description |
Remarks |
|---|---|---|
| 2993 | uuid error, verification code verification failed | |
| 2994 | Parameter error | |
| 2996 | Two requests are within the minimum interval | |
| 2997 | Number changed. Get a verification code first | |
| 2998 | Network error | |
| 2999 | Other error | |
| 3001 | Request timeout | |
| 4204 | Invalid mobile number | |
| 4001 | body is empty | |
| 4002 | Invalid appkey | |
| 4003 | Invalid source | |
| 4004 | body decryption failed | |
| 4005 | aes key decryption failed | |
| 4006 | Timestamp conversion failed | |
| 4007 | Incorrect body format | |
| 4008 | Invalid timestamp | |
| 4009 | No SMS verification permission | |
| 4011 | Sending frequency exceeded | There is no limit on the number of verification codes obtained per day for the same mobile number. For notifications, the same content is limited to 3 messages in 10 minutes, while different content is unlimited. Marketing messages are limited to 3 messages in 10 minutes. |
| 4012 | api does not exist | |
| 4013 | Template does not exist | |
| 4014 | extra is empty | |
| 4015 | Incorrect verification code | |
| 4016 | No balance | |
| 4017 | Verification code timed out | |
| 4018 | Verification code has already been verified | |
| 5000 | Server error |