Swiftpack.co - Package - iProov/ios

iProov iOS SDK v7.0.0

🤳 Introduction

The iProov iOS SDK allows you to integrate iProov into your iOS app. We also have an Android SDK and HTML5 client.

The iProov iOS SDK is a binary iOS dynamic framework. It is supported on devices running iOS 9.0 and above, on both iPhones and iPads, using Xcode 10.2.1 (see note below regarding Xcode version compatibility).

The framework has been written in Swift, and we recommend use of Swift for the simplest and cleanest integration, however it is also possible to call iProov from within an Objective-C app using our Objective-C wrapper, which provides an Objective-C friendly API to invoke the Swift code.

📖 Contents

The framework package is provided via this repository, which contains the following:

  • README.md -- this document
  • WaterlooBank -- a folder containing an Xcode sample project of iProov for the fictitious Waterloo Bank written in Swift.
  • WaterlooBankObjC -- a folder containing an Xcode sample project for Waterloo Bank written in Objective-C.
  • iProov.framework & iProov.podspec -- these are the files which will be pulled in automatically by Cocoapods. You do not need to do anything with these files.

⚠️ Important notice regarding Xcode compatibility

Please note that iProov is distributed as a compiled binary framework. Due to current Swift limitations, this means that the version of Xcode (and the version of Swift) that was used to compile the iProov framework must exactly match the version of Xcode used to compile your app.

The version of Xcode used to compile v7.0.0 of the SDK is Xcode 10.2.1 (Swift 5.0.1).

Therefore, this is the only supported version of Xcode for iProov. If you are using an older version of Xcode and cannot upgrade for whatever reason, you will need to use an older version of the SDK (contact iProov for further details).

NOTE: With the addition of module stability in Swift 5.1 we look forward to providing an updated version of the SDK with the release of iOS 13 later this year, which will support multiple Swift compiler versions.

⬆️ Upgrading from v6.x or earlier

Welcome to the next generation of the iProov SDK! v7 is a substantial overhaul to the SDK and added many new features, and as a result SDK v7 is a major update and includes breaking changes!

Please consult the Upgrade Guide for detailed information about how to upgrade your app, and look out for the ⬆️ symbol in this README.

✍️ Registration

You can obtain API credentials by registering on the iProov Partner Portal.

📲 Installation

Integration with your app is supported via both Cocoapods and Carthage. We recommend Cocoapods for the easiest installation.

Cocoapods

  1. If you are not yet using Cocoapods in your project, first run sudo gem install cocoapods followed by pod init. (For further information on installing Cocoapods, click here.)

  2. Add the following to your Podfile (inside the target section):

    pod 'iProov'
    
  3. Run pod install.

  4. Add an NSCameraUsageDescription entry to your app's Info.plist, with the reason why your app requires camera access (e.g. “To iProov you in order to verify your identity.”)

Carthage

Cocoapods is recommend for the easiest integration, however we also support Carthage. Full instructions installing and setting up Carthage are available here.

Add the following to your Cartfile:

github "socketio/socket.io-client-swift" == 15.1.0
github "kishikawakatsumi/KeychainAccess" ~> 3.2.0
github "SwiftyJSON/SwiftyJSON" ~> 4.0.0
binary "https://raw.githubusercontent.com/iProov/ios/master/carthage/IProov.json"

⬆️ UPGRADING NOTICE: Take note of the new dependencies & versions!

After installation, you will need to add an NSCameraUsageDescription entry to your app's Info.plist, with the reason why your app requires camera access (e.g. “To iProov you in order to verify your identity.”)

🚀 Get started

Before being able to launch iProov, you need to get a token to iProov against. There are 3 different token types:

  1. A verify token - for logging in an existing user
  2. An enrol token - for registering a new user
  3. An ID match token - for matching a user against a scanned ID document image.

In a production app, you normally would want to obtain the token via a server-to-server back-end call. For the purposes of on-device demos/testing, we provide Swift/Alamofire sample code for obtaining tokens via iProov API v2 with our open-source iOS API Client.

⬆️ UPGRADING NOTICE: This is a significant change from pre-v7 SDK where for ease of debugging/development, the SDK could be passed an API key and then obtain the token for you automatically. This should never have been used for production apps anyway, and the functionality is no longer part of the SDK.

Once you have obtained the token, you can simply call IProov.launch(...):

let token = "{{ your token here }}"

IProov.launch(token: token, callback: { (status) in

	switch status {
	case let .processing(progress, message):
		// The SDK will update your app with the progress of streaming to the server and authenticating
		// the user. This will be called multiple time as the progress updates.
	    
	case let .success(token):
	    // The user was successfully verified/enrolled and the token has been validated.
	    // The token passed back will be the same as the one passed in to the original call.
	    
	case let .failure(reason, feedback):
		// The user was not successfully verified/enrolled, as their identity could not be verified,
		// or there was another issue with their verification/enrollment, and a reason (as a string)
		// is provided as to why the claim failed.
		
	case .cancelled:
		// The user cancelled iProov, either by pressing the close button at the top right, or sending
		// the app to the background.
	    
	case let .error(error):
		// The user was not successfully verified/enrolled due to an error (e.g. lost internet connection)
		// along with an `iProovError` with more information about the error (NSError in Objective-C).
		// It will be called once, or never.
		
	}
	
}

By default, iProov will stream to our EU back-end platform. If you wish to stream to a different back-end, you can pass a streamingURL as the first parameter to IProov.launch() with the base URL of the back-end to stream to.

⚠️ SECURITY NOTICE: You should never use iProov as a local authentication method. You cannot rely on the fact that the success result was returned to prove that the user was authenticated or enrolled successfully (it is possible the iProov process could be manipulated locally by a malicious user). You can treat the success callback as a hint to your app to update the UI, etc. but you must always independently validate the token server-side (using the validate API call) before performing any authenticated user actions.


⬆️ UPGRADING NOTICE: In v7 you no longer need to call IProov.verify() or IProov.enrol(). There were previously 6 separate methods to launch iProov, these have now been combined into a single method. (Push & URL launched claims are no longer handled within the SDK itself).


⬆️ UPGRADING NOTICE: Previously, after launching iProov, the SDK would handle the entire user experience end-to-end, from getting a token all the way through to the streaming UI and would then pass back a pass/fail/error result to your app. In v7, the SDK flashes the screen and then hands back control to your app, whilst the capture is streamed in the background. This means that you can now control the UI to display your own streaming UI, or allow the user to continue with another activity whilst the iProov capture streams in the background.

⚙ Options

You can customize the iProov session by passing in an Options object when launching iProov and setting any of these variables:

let options = Options()

/*
	UIOptions
	Configure options relating to the user interface
*/

options.ui.locale = Locale(identifier: "en") // Overrides the device locale setting for the iProov SDK. Must be a 2-letter ISO 639-1 code: http://www.loc.gov/standards/iso639-2/php/code_list.php
options.ui.filter = .shaded // Adjust the filter used for the face preview. Can be .classic (as in pre-v7), .shaded (additional detail, the default in v7) or .vibrant (full color).

// Adjust various colors for the camera preview:
options.ui.lineColor = .white
options.ui.backgroundColor = .black
options.ui.loadingTintColor = .lightGray
options.ui.notReadyTintColor = .orange
options.ui.readyTintColor = .green

options.ui.title = "Authenticating to ACME Bank" // Specify a custom title to be shown. Defaults to nil which will show an iProov-generated message. Set to empty string ("") to hide the message entirely.
options.ui.regularFont = "SomeFont"
options.ui.boldFont = "SomeFont-Bold"
options.ui.fonts = ["SomeFont", "SomeFont-Bold"] // If using custom fonts, specify them here (don't forget to add them to your Info.plist!)
options.ui.logoImage = UIImage(named: "foo")
options.ui.scanLineDisabled = false // Disables the vertical sweeping scanline whilst flashing introduced in SDK v7
options.ui.autoStartDisabled = false // Disable the "auto start" countdown functionality. The user will have to tap the screen to start iProoving.
options.ui.presentationDelegate = MyPresentationDelegate() // See the section below entitled "Custom IProovPresentationDelegate".


/*
	NetworkOptions
	Configure options relating to networking & security
*/

options.network.certificates = [Bundle.main.path(forResource: "custom_cert", ofType: "der")!] // Supply an array of paths of certificates to be used for pinning. Useful when using your own proxy server, or for overriding the built-in certificate pinning for some other reason. Certificates should be generated in DER-encoded X.509 certificate format, eg. with the command: $ openssl x509 -in cert.crt -outform der -out cert.der
options.network.certificatePinningDisabled = false	// Disables SSL/TLS certificate pinning to the server. WARNING! Do not enable this in production apps.

/*
	CaptureOptions
	Configure options relating to the capture functionality
*/

// You can specify max yaw/roll/pitch deviation of the user's face to ensure a given pose. Values are provided in normalised units.
// These options should not be set for general use. Please contact iProov for further information if you would like to use this feature.

options.capture.maxYaw = 0.03
options.capture.maxRoll = 0.03
options.capture.maxPitch = 0.03

Custom IProovPresentationDelegate

In previous versions of the SDK, when presenting the iProov UI the SDK would get a reference to the app delegate's window's rootViewController, then iterate through the stack to find the top-most view controller, and then present() iProov's view controller as a modal view controller from the top-most view controller on the stack.

This resulted in an easy-to-use zero-config API surface, however this didn't necessarily work well for all cases, (e.g. modals from modals, or where it would be desirable to push iProov into an existing UINavigationController flow).

We listened to your feedback! SDK v7.0 still provides the existing behaviour as a default, however it is now possible to pass a custom presentationDelegate to the UI options, which allows you to override the presentation/dismissal behaviour of the iProov view controller:

extension MyViewController: IProovPresentationDelegate {

    func present(iProovViewController: UIViewController) {
        // How should we present the iProov view controller?
    }

    func dismiss(iProovViewController: UIViewController) {
        // How should we dismiss the iProov view controller once it's done?
    }

}

⚠️ IMPORTANT: There are a couple of important rules you must follow when using this functionality:

  1. With great power comes great responsibility. The iProov view controller requires full cover of the entire screen in order to work properly. Do not attempt to present your view controller to the user in such a way that it only takes up part of the screen, or is obscured by other views. Also, you must ensure that the view controller is entirely removed from the user's view once dismissed.

  2. To avoid the risk of retain cycles, Options only holds a weak reference to your presentation delegate. Ensure that your presentation delegate is retained for the lifetime of the iProov capture session, or you may result in a defective flow.


📲 iOS 13 BETA: If you're building a Swift UI based app (iOS 13+), you will need to produce your own custom presentation delegate, as there is no longer the concept of the app delegate window. We intend to provide an updated default presentation delegate prior to the release of iOS 13 later this year which fully supports Swift UI based apps, however for now this functionality should enable you to roll your own solution.

🌎 String localization & customization

The SDK ships with localized strings for the following locales:

  • English
  • Norwegian Bokmål
  • Norwegian Nynosk
  • Dutch
  • Turkish

If the user's device language is set to one of the above, the SDK will be localized accordingingly unless options.ui.locale is set, in which case this setting will override the default locale.

It is also possible to manually customize any of the strings in the app, regardless of locale.

💥 Handling failures & errors

Failures

Failures occur when the user's identity could not be verified for some reason. A failure means that the capture was successfully received and processed by the server, which returned a result. Crucially, this differs from an error, where the capture could not be completed for some reason.

Failures are caught via the .failure(reason, fallback) enum case in the callback:

reason - The reason that the user could not be verified/enrolled. You should present this to the user as it may provide an informative hint for the user to increase their chances of iProoving successfully next time

feedback - Where available, provides additional feedback on the reason the user could not be verified/enrolled. Some possible values are:

  • ambiguous_outcome
  • network_problem
  • user_timeout

Errors

Errors occur when the capture could not be completed due to a technical problem or user action which prevents the capture from completing. Errors originate from the device, as opposed to iProov's servers.

Errors are caught via the .error(error) enum case in the callback. The error parameter provides the reason the iProov process failed as an IProovError.

A description of these cases are as follows:

  • captureAlreadyActive - An existing iProov capture is already in progress. Wait until the current capture completes before starting a new one.
  • streamingError(String?) - An error occurred with the video streaming process. Consult the error associated value for more information.
  • encoderError(code: Int32?) - An error occurred with the video encoder. Report the error code to iProov for further assistance.
  • lightingModelError - An error occurred with the lighting mode. This should be reported to iProov for further assistance.
  • cameraError(String?) - An error occurred with the camera.
  • cameraPermissionDenied - The user disallowed access to the camera when prompted.
  • serverError(String?) - A server-side error/token invalidation occurred. The associated string will contain further information about the error.

❓Help & support

For further help with integrating the SDK, please contact support@iproov.com.

Github

link
Stars: 6
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

7.0.0 - Jul 15, 2019

This production release incorporates all the changes from 7.0.0-beta1, 7.0.0-beta2 & 7.0.0-beta3:

🔌 The streaming process is now asynchronous - Previously, the iProov SDK controlled the UI whilst streaming, and then provided a result back to your app once the entire process was completed. v7 now hands back control to your app after the screen flashing, you can provide your own streaming progress UI or allow the user to continue with other activities whilst the capture streams in the background.

🕯 Overhauled lighting model - v7 introduces our next-generation evolutionary and adaptive lighting model. This means iProov will now perform better in a wider range of environmental lighting conditions and provide more useful user feedback.

🤠 Additional filter options are now available - Along with the classic canny visual filter, there is now a new default “shaded” feature which adds a hint of colour, as well as a “vibrant” option which provides a full-colour more detailed visual effect.

🧭 Pose control - It is now possible to set maximum roll/pitch/yaw values to obtain front-on “selfie” images from the SDK to enable the use of the iProov image in an interchangeable format for other face matching use cases.

🎨 Greater customisation options - It is now possible to specify a title whilst iProoving, and to pass a custom presentation delegate to control how the iProov view controller is presented and dismissed in more complex UI journeys.

🖌 UI improvements - Following user feedback there is now a vertical scan-line which sweeps up the screen whilst iProoving. When using auto-start, the 3 second numeric countdown has been replaced with a 2 second progress bar along the bottom. The UI has been updated for consistency with our nextgen Android & HTML5 clients.

🛠 Simplified API surface - Previously there were 6 different ways to launch iProov, all of which have now been replaced with IProov.launch().

🗑 Legacy features have been removed - Privacy policy and instructions UI has now been removed from the SDK. The functionality obtain tokens has also been removed from within the SDK (which should never have been used in production anyway) and is instead now provided by the iOS API Client. Push and URL claims are no longer supported directly within the SDK and should instead be implemented within your app.

✂️ Third-party dependencies have been reduced - As a result of removing the legacy features, it has been possible to remove Alamofire, AlamofireImage, GPUImage & MBProgressHUD as dependencies, resulting in smaller SDK size. A lightweight fork of GPUImage2 is included, bundled-into the SDK.

🕷 Bugfixes - The main thread checker warning from GPUImage has been fixed, along with various other minor issues and performance optimisations.

🧹 Many other minor improvements - Optimisations for the iPhone X, Xs & Xs Max, haptic feedback on supported devices, refactored Options API for clarity and consistency, improvements to localisation, and use of Vision Framework on iOS 11+ for more accurate face detection.

7.0.0-beta3 - Jul 9, 2019

v7.0.0-beta3 makes a few small tweaks to beta2 as we approach the release of v7.0.0 to production (planned for the end of this week), based on internal and customer feedback.

Changes since v7.0.0-beta2

  • Added support for presentationDelegate to Options.UI - it is now possible to set a custom delegate to handle the presentation & dismissal of the iProov view controller. This means that you now have control over how iProov's view controller is displayed, and opens up a great deal of flexibility (for example, presenting iProov within a UINavigationController flow). See this section of the README for more information and examples.

  • Added new title property to Options.UI - you can now pass a custom title string to be displayed at the top of the iProov view controller, to replace the default iProov-generated title. As a result of this, the messageHidden property has now been removed (you can simply pass empty string ("") to title to have no title at all). See the Options section of the README for more information and examples.

  • UI changes - the logo image has now been moved to the right-hand side, and the close button has been moved to the left-hand side.

  • Upgraded Socket.IO to 15.1.0 - we have updated to the latest version of socket.io-client-swift.

7.0.0-beta2 - Jun 20, 2019

v7.0.0-beta2 builds upon the progress made in beta1 by adding the remaining functionality required for the next-generation SDK platform, and further refines and optimises the improvements in beta1.

Barring any showstoppers, we anticipate this to be the final beta before v7.0.0 production release.

Major changes since v7.0.0-beta1

  • Lighting model is now enabled. The next-generation evolutionary and adaptive lighting model has now been integrated and enabled. This means iProov will now perform better in a wider range of environmental lighting conditions and provide more useful feedback to the user about whether they are likely to be able to successfully iProov in particularly bright environments. IMPORTANT: Please note that at this the lighting model is still undergoing training and will be refined further over time.

  • New filters. It is now possible to customise the video filter which is applied to the face. The new default is called .shaded and applies a light level of shading with more detail to the user's face. Other options include .classic (which reverts to the original monochromatic design pre-v7.0.0-beta2) and .vibrant which dials up the colour vibrancy to the max! See the README for additional details.

  • Introducing iOS API Client. The Sample Code has now been removed from the SDK repo and has been moved to its own separate framework which can be found here.

Minor changes since v7.0.0-beta1

  • Haptic feedback. Rather than the phone vibrating to provide user feedback, on iOS devices with the Taptic Engine, the device will now more gracefully "tap" when the face is found and at the start of flashing.

  • Refactor to Options. The Options API has been updated for additional clarity and consistency. See the README for additional details.

  • Misc other improvements. Improvements to localisation and error handling, minor improvements to the UI for aligning the face,

7.0.0-beta1 - Apr 10, 2019

Main changes

  • Breaking API changes. Previously there were 6 different ways to launch iProov, which have now all been replaced with IProov.launch().

  • The streaming process is now asynchronous. Previously, the iProov SDK controlled the UI whilst streaming, and then provided a result back to your app once the entire process was completed. v7 now hands back control to your app after the screen flashing, you can provide your own streaming progress UI or allow the user to continue with other activities whilst the capture streams in the background. This required an overhaul of the public API.

  • There is no built-in UI for streaming progress. This is part of making the SDK asynchronous (see above). You should now provide your own UI for streaming progress (if desired).

  • Push & URL claims are no longer supported as distinct launch methods. Just iProov against a token obtained from a push notification/URL as normal, and implement this behaviour (if required) in your own app.

  • The SDK no longer has fetching a token as built-in functionality. Prior to v7 of the SDK it was possible to launch iProov with only a service provider, this functionality has been removed, and you should obtain a token through a secure server-to-server call from your back-end to iProov. For local development purposes, you can obtain a token using the demo API client in the the Waterloo Bank sample code.

  • Privacy policy & instructions are no longer part of the SDK. You should ensure you obtain suitable user consent within your app for iProov, and suitable instructions are provided to the user prior to iProoving. Contact us for further details on this.

Other changes

  • Alamofire, AlamofireImage & MBProgressHUD are removed as dependencies.
  • GPUImage no longer a standalone dependency, a lightweight fork of GPUImage2 is now bundled-in.
  • Optimized for iPhone X, Xs & Xs Max.
  • Overhauled, more robust lighting model (to follow in future beta).
  • Vertical scan-line whilst iProoving.
  • The 3 second auto-start countdown has been replaced with a 2 second progress bar.
  • iProovConfig has been renamed to Options.
  • Fixes main thread warnings from GPUImage.