mCheck SDK
mCheck SDK for-ios 允许您在移动设备中集成手机号码验证 API。
为了测试示例,您需要更改密钥。
示例
要运行示例项目,首先克隆仓库,然后在示例目录中运行 pod install
安装
MCheck 可以通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中
pod 'MCheck'
样本用法
初始化 SDK
//automatically generated token from https://isms.center
NSString *token = @"YOUR_TOKEN";
self.mCheck = [[MCheck alloc] initWithToken:token];
请求验证
// [:phone] phone number
// [:pin] validation code
NSString *phone = "+77770000000";
NSString *smsBody = @"Your validation code: [:pin]"; // smsBody is optional param, and maybe is null
[self.mCheck requestValidationWithPhone:phone type:SMS message:smsBody callback:^(MCheckRequestValidationResult *result, NSError *error) {
if (error) {
return;
}
//[self showMessage:[NSString stringWithFormat:@"Success, request ID: %ld", (long)result.rid]];
}];
验证 Pin
NSString *requestID = @""; //request id received from [self.mCheck requestValidationWithPhone] - response.id
NSString *pinCode = @""; //pin code to check
[self.mCheck verifyValidationWithRequestId:requestID pin:pinCode callback:^(MCheckVerifyValidationResult *result, NSError *error) {
if (error) {
return;
}
//[self showMessage:[NSString stringWithFormat:@"Validated: %@", result.validated ? @"YES" : @"NO"]];
}];
验证状态
NSString *requestID = @""; //request id received from [self.mCheck requestValidationWithPhone] - response.id
[self.mCheck checkValidationStatusWithRequestId:requestID callback:^(MCheckValidationStatusResult *result, NSError *error) {
if (error) {
return;
}
//[self showMessage:[NSString stringWithFormat:@"Validated: %@", result.validated ? @"YES" : @"NO"]];
}];
许可
MCheck 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。