测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可 | 商业 |
发布最后一个发布 | 2015年2月 |
由 Peter Schaeffer,Pierrick,Bertrand Villain 维护。
CaptchaFace 是一种通过相机识别多个视觉步骤来识别移动用户是否真实人类的工具。
#import <CaptchaFace/UIViewController+CaptchaFace.h>
或Swift中的import CaptchaFace
在任何需要的地方包含 CaptchaFace。要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。使用 CocoaPods,您可以从命令行运行 pod try CaptchaFace
。
确保您还能看到 Cocoadocs 上的 CaptchaFace 文档 CaptchaFace 文档在 Cocoadoс。
注意:要使用 SDK,您需要从 CaptchaFace 网站 获取 API 密钥。
将以下导入添加到文件顶部或 Swift 的桥接头部
#import <CaptchaFace/UIViewController+CaptchaFace.h>
使用
// Objective-C
[UIDevice supportsCapchaFace]
```
```swift
// Swift
UIDevice.supportsCapchaFace()
显示带有默认参数的 captcha view 控制器(必须从任何应用程序的 ViewController 中调用)
// Objective-C
[self showCaptchaViewControllerWithLicenceKey:@"<your_key>" completion:^(NSError *error, int successCount, int totalCount) {
//Handle success and failure, see CaptchaFaceViewController.m in the Sample project for examples
}];
// Swift
self.showCaptchaViewControllerWithLicenceKey("<your_key>", completion: { (error:NSError!,successCount:Int32, totalCount:Int32) -> Void in
//Handle success and failure, see CaptchaFaceSwiftViewController.swift in the Sample project for examples
})
如果您想要自定义 captchaFace 会话期间显示的事件,您必须创建一个 CaptchaFaceScenario 对象。可以使用 CaptchaFaceScenario 方法以随机事件创建此对象。
创建一个 CaptchaFaceScenario
// Objective-C
NSRange eventsRange= {3,2};
//3 to 5 random events will be played
CaptchaFaceScenario *scenario = [CaptchaFaceScenario scenarioWithRandomEvents:eventsRange intervalBetweenEvents:1.0 failureTimeInterval:5.0];
// Swift
let eventsRange = NSMakeRange(3, 2)
//3 to 5 random events will be played
let scenario = CaptchaFaceScenario(randomEvents: eventsRange, intervalBetweenEvents: 1.0, failureTimeInterval: 5.0)
// Objective-C
NSArray *events = @[[CaptchaFaceEvent smile],[CaptchaFaceEvent moveBackward],[CaptchaFaceEvent moveForward]];
CaptchaFaceScenario *scenario = [CaptchaFaceScenario scenarioWithEvents:events intervalBetweenEvents:1.0 failureTimeInterval:5.0];
// Swift
let events = [CaptchaFaceEvent.smile(),CaptchaFaceEvent.moveBackward(),CaptchaFaceEvent.moveForward()]
let scenario = CaptchaFaceScenario(events: events, intervalBetweenEvents: 1.0, failureTimeInterval: 5.0)
使用创建的场景显示验证码视图控制器
// Objective-C
[self showCaptchaViewControllerWithLicenceKey:@"<your_key>" scenario: scenario completion:^(NSError *error, int successCount, int totalCount) {
//Handle success and failure, see CaptchaFaceViewController.m in the Sample project for examples
}];
// Swift
self.showCaptchaViewControllerWithLicenceKey("<your_key>", scenario: scenario completion: { (error:NSError!,successCount:Int32, totalCount:Int32) -> Void in
//Handle success and failure, see CaptchaFaceSwiftViewController.swift in the Sample project for examples
})
Wassa, [email protected]