CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

CaptchaFace 1.0.4

CaptchaFace 1.0.4

TestsTested
LangLanguage Obj-CObjective C
License Commercial
ReleasedLast Release Feb 2015

Maintained by Peter Schaeffer, Pierrick, Bertrand Villain.



  • By
  • wassa

CaptchaFace is a tool that allows you to know if a mobile user is really human by identification of several visual steps through the camera.

Installation

Manual installation

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Drag and drop the Pod directory from the archive in your project navigator. Make sure to select Copy items when asked if you extracted the code archive outside of your project.
  3. Download the opencv library and drag and drop the opencv2.framework in your project navigator.
  4. Add the opencv dependancies in your project properties in Build Phases > Link with libraries :
    • libstdc++
    • Accelerate
    • AssetsLibrary
    • AVFoundation
    • CoreGraphics
    • CoreImage
    • CoreMedia
    • CoreVideo
    • Foundation
    • QuartzCore
    • UIKit
  5. Include CaptchaFace wherever you need it with #import <CaptchaFace/UIViewController+CaptchaFace.h> from Objective-C or import CaptchaFace from Swift.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first. With CocoaPods , you can run pod try CaptchaFace from the command line.

Make sure you also see CaptchaFace documentation on Cocoadocs.

Attention : To use the SDK, you need a API key that you can get on the CaptchaFace website

Basics

  1. Add the following import to the top of the file or the bringing header for swift:

    #import <CaptchaFace/UIViewController+CaptchaFace.h>
  2. Check if the user can run CaptchaFace using :

        // Objective-C
        [UIDevice supportsCapchaFace]
        ```
        ```swift
        // Swift
        UIDevice.supportsCapchaFace()
  3. Show the captcha viewController with default parameters ( have to be called from any application's 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
    
    })
    

Advanced

If you want to personalize the event shown during the captchaFaceSession, you have to create a CaptchaFaceScenario object. This object can be created with random events in a range with the method :

  1. Create a CaptchaFaceScenario :

    • with random number of events within a range that you can define and custom timings
    // 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)    
    • with Fixed events by creating an array of CaptchaFaceEvent
    // 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)
  1. Show the captcha viewController with the created scenario :

    // 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
    
    })
    

Requirements

  • Xcode 5
  • iOS 7
  • ARC
  • Devices responding to [UIDevice supportsCapchaFace], typically iPhones from iphone 4 and iPads from iPad 2

Author

Wassa, [email protected]