Logo

ScanTrust iOS SDK

Version: 1.3.0.alpha

ScanTrust iOS SDK is the native SDK for the ScanTrust Scan Engine.

Contents

  1. Installation
  2. Getting Started
    1. Prerequisites
  3. STCameraManager Setup And Management
    1. Setup
    2. STCameraManager Handling
    3. Results
  4. StLimitedCameraManager Setup and Management
    1. Setup
    2. StLimitedCameraManager Handling
    3. Results
  5. Utilities
    1. STPhoneManager

Installation

  • Copy and Paste all the necessary header and lib files to your project and don’t forgot to check App target
  • Add the below frameworks into your xCode project
    • libSTAuthenticate.a
    • libconv.tbd
    • UIKIT.framework
    • Foundation.framework
    • CoreGraphics.framework
    • AVFoundation.framework
    • QuartzCode.framework
    • SystemConfiguration.framework
  • Depending on how you set up your project, the standard c++ library may or not be included by default.

If you are using swift as the development language, you need to import the framework’s headers into the bridging header file.

#import <STAuthenticate/STCameraManager.h>`
#import <STAuthenticate/STLimitedCameraManager.h>`

Getting Started

The SDK offers the management of the camera, the image processing of the incoming frames and other features includes some utility functions.

Prerequisites

To authenticate or scan the secure QR codes there are some limits, only the iPhones which has higher quality iSight camera can scan the secure QR codes. For other iPhones, iPads and iPods the SDK will work like a normal QR code reader and it will give the scanned QR code URL/Text back. To get to know more about compatible phones please check this link or use the SDK utility method to identify current device is compatible for authenticating ScanTrust code or not.

  • Minimum deployment target as iOS 8.0 and above.
  • In order for SDK to work, the following device permissions are required.
    • Camera <key>NSCameraUsageDescription</key> <string>To scan QR codes</string>
    • Location <key>NSLocationWhenInUseUsageDescription</key> <string>Location is required to find out where you are</string>
  • SDK will make network requests to ScanTrust backend, so add the host names under App Transport Security Settings in Info.plist
  • Camera preview view must be full screen excluding the navigation bar and status bar

STCameraManager Setup And Management

The entry point of the ScanTrust Processing is the STCameraManager, this class does all the heavy lifting, setting up the camera and the preview (view finder) view, running the image processing on the incoming frames and reporting the various outcomes.

Setup

The manager class is a singleton and provides easy way to setup and start the camera with preview view.

In viewWillAppear() method, call setUpCameraSessionWithPreview: error: to setup the preview view and initialize the camera object.

#import <STAuthenticate/STCameraManager.h>

@implementation ViewController
#pragma mark - View life cycle methods
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSError *error;
    // Considering you have UIView called preview setup in storyboard/XIB or in code
    [STCameraManager sharedInstance] setUpCameraSessionWithPreview:previewView error:error];
}
@end

SDK does provides STPreviewView to setup the camera preview in Storyboard or create a new instance.

STCameraManager Handling

The sharedInstance camera manager provides following method to control the camera and it is up to the user to determine when to start and stop the camera or processing. But in general the camera is started in the onResume() method and stoped on onPause()

- (void)onResume {
  [STCameraManager sharedInstance] setCameraTorchModeOnOff: YES];
  [STCameraManager sharedInstance] startScanning];
}

- (void)onPause {
  [STCameraManager sharedInstance] setCameraTorchModeOnOff: NO];
  [STCameraManager sharedInstance] pauseScanning];
}
Public Methods Description
- (void)startScanning; Starts the underlying camera object, its preview and starts the ScanTrust frame processing.
- (void)pauseScanning; stops the preview and stops the ScanTrust frame processing.
- (void)resumeScanning; Restarts the ScanTrust frame processing. Should be used when the frame processing has been paused. Note: this will not have an impact on the camera or its preview, but will restart the response flow.
- (void)setCameraTorchModeOnOff:(BOOL)turnOn; Turns the torch on or off depending on the value of turnOn.

Results

The results are organized as follows:

Report Types: Define the states of the flow

Report Type Description
COMPLETED_RESULT Designs a response that needs special attention and therefore that has caused the ScanTrust image processing to stop. The user will need to call startScanning() to restart the flow.
IN_PROGRESS Designs a response that will not stop the ScanTrust frame processing, the responses will keep coming as long as the user doesn’t manually stop the flow or the camera or as long as a COMPLETED_RESULT doesn’t occur.
UNSUPPORTED_RESULT Designs a response obtained on an unsupported phone. The processing flow may or many not stop depending on the outcome of the scans.

Scan States: Define the states of the individual scans

Scan State Description
UNREADABLE No QR code has been detected by Zxing or the QR code that has been detected does not have all four required pattern centres
OK The code belongs to ScanTrust and all the constraints are met
TOO_SMALL A code belonging to ScanTrust has been detected, but the minimum size constraint has failed
BLURRY A code belonging to ScanTrust has been detected, but has been classified as too blurry
NOT_PROPRIETARY A code has been detected, but it doesn’t belong to ScanTrust
FP_NOT_IN_FRAME A hybrid code belonging to ScanTrust has been detected, but the external fingerprint zone is not in the frame
NO_AUTH A code with no authentication feature belonging to ScanTrust has be found

The scan states are distributed among the report types as shown in the following figure and table

venn diagram

Report Type Scan State Description
COMPLETED_RESULT OK A scan is ready to be sent to the server for authentication
BLURRY An insufficient quality event has occurred and the best scan is ready to be sent to the server
NOT_PROPRIETARY A code has been detected, but it doesn’t belong to ScanTrust
NO_AUTH A code with no authentication feature belonging to ScanTrust has be found
IN_PROGRESS OK A scan of a code belonging to ScanTrust has met all the constraints
BLURRY A code belonging to ScanTrust has been detected, but has been classified as too blurry
UNREADABLE No QR code has been detected by Zxing or the QR code that has been detected does not have all four required pattern centres
FP_NOT_IN_FRAME A hybrid code belonging to ScanTrust has been detected, but the external fingerprint zone is not in the frame
TOO_SMALL A code belonging to ScanTrust has been detected, but the minimum size constraint has failed
UNSUPPORTED_RESULT UNREADABLE No QR code has been detected by Zxing or the QR code that has been detected does not have all four required pattern centres
OK The code belongs to ScanTrust. The processing will be stopped
NOT_PROPRIETARY A code has been detected, but it doesn’t belong to ScanTrust. The processing will be stopped

Camera manager does provide below delegate methods to know the result during ScanTrust image processing. STScanState is a enum and matches the above Scan State table

@protocol STCameraManagerDelegate <NSObject>
@optional
- (void)cameraManager:(STCameraManager *)cameraManager didProcessFrameWithScanState:(STScanState)scanState;
@end

didProcessFrameWithScanState notifies the delegate when there is a camera frame processed and have a defined Scan State

StLimitedCameraManager Setup and Management

The StLimitedCameraManager does the same camera and preview view setup as the STCameraManager but does not perform the image and frame processing required for the ScanTrust authentication. It is limited to checking the ownership of the code based on its content.

Setup

By default It will enable the reading of 1D barcodes (UPC-A, UPC-E, EAN-8, EAN-13, Code 39, Code 93, Code 128, ITF(Interleaved Two of Five), RSS 14, RSS EXPANDED) and QR codes and it’s instantiation should be done in the same way as for the STCameraManager.

StLimitedCameraManager Handling

The manager gives access to the same methods as the STCameraManager

Results

The results obtained with the StLimitedCameraManager are:

Report Type Scan State Description
COMPLETED_RESULT OK A code belonging to ScanTrust has been detected (processing is paused)
NOT_PROPRIETARY A code has been detected, but it doesn’t belong to ScanTrust or is undetermined (processing is paused)
IN_PROGRESS UNREADABLE No code has been detected by Zxing

Limited Camera manager provides a delegate method to know the result.

@protocol STLimitedCameraManagerDelegate <NSObject>
@optional
- (void)cameraManager:(STLimitedCameraManager *)cameraManager didCompleteScanWithScanResult:(STScanResult *)scanResult;
@end

STScanResult class gives the scanned code data and STScanState

Utilities

STPhoneManager

The STPhoneManager is a compatibility manager and a utility class that is used to assess the phone’s state/compatibility in relation to

  • ScanTrust’s Secure Graphic authentication (isPhoneSupported)
  • Request/check access to camera (requestPersmissionForCamera and isAuthorizedForCamera)
  • Device details like model, Name, OS and version

© 2017 ScanTrust, SA