iOS Integration (2.x)
- Matt Gray (Unlicensed)
- Sharmeen Hussain
- Aubrey Kilian
- Deborah Cross (Unlicensed)
IMPORTANT NOTICE: The mobile SDK has been deprecated and no longer offered as an integration option in greenID. For alternative options, please contact your GBG account representative.
Getting started
There are several things you will need in order to integrate the greenID SDK into your code.
- Xcode version 12 or later (Current latest is 12.4). Xcode can be downloaded for free from the Apple App Store. You will require an Apple ID to download Xcode.
- A copy of the greenID SDK zip file for iOS. This contains the greenID framework, as well as several other framework files that are required to make greenID work
- A project in Xcode, using Objective-C or Swift, targeting iOS 10 or later. You can use an existing project, or you may want to use our iOS sample code to get started.
- Some 3rd party frameworks require Swift, and your project will need to be compiled using Swift 5.
- Several account settings from the greenID Mobile team. You will not be able to use the greenID SDK without the necessary account information. At a minimum,
accountID,
apiCode, mode, countryCode
andbaseURL
will be required. Other configuration variables may be required as you do further integration and testing. - To test your code, you will need to run it on a physical device. You will need an Apple Developer account to load your app onto a physical device.
Adding the greenID SDK to your project
Add frameworks and bundles to your project
- Uncompress the greenID SDK zip file.
- In the Finder, copy the framework bundles (
GIDSDK.framework, MJCS.framework,
IDSLiveness.framework and GIDResources.bundle
) to the root folder of your project. - Open your project in Xcode. Expand your project in the left pane. There should be a
Frameworks
group in you project directory in Xcode. Right click on theFrameworks
group and select theAdd files to "(Your project name)"...
option from the menu. - Select the four frameworks/bundles (
GIDSDK.framework, MJCS.framework,
IDSLiveness.framework and GIDResources.bundle
)
from the file dialog listing. You can use shift-click or command-click to select multiple bundles at once. - Click on the
Options
button at the bottom of the dialog. Select the project targets that the bundles should be added to. Also ensure theCopy items if needed
and theCreate groups
options are selected. When the five frameworks/bundles have been selected, and the options have been set, click theAdd
button. The five items should now show in theFrameworks
folder in your Xcode project. - There are three additional frameworks required. These can be downloaded from the 3rd party links below, and installed manually, or included in your project using a package management system such as CocoaPods or Carthage.
The required frameworks are:
Set up embedded binaries
- Go to (Your Project Target) → General → Frameworks, Libraries, and Embedded Content.
- Add the following required libraries if they are not already included in your project:
- AudioToolbox.framework
AVFoundation.framework
CoreGraphics.framework
CoreMedia.framework
CoreVideo.framework
MobileCoreServices.framework
OpenGLES.framework
QuartzCore.framework
Security.framework
ImageIO.framework
Foundation.framework
UIKit.framework
- The
GIDSDK.framework,
MJCS.framework,
IDSLiveness.framework, AFNetworking.framework, ZipZap.framework, FLAnimatedImage.framework
, Lottie.framework
should have been automatically added to the Frameworks, Libraries, and Embedded Content group. If not, add them manually. The easiest way to do this is to drag the framework file(s) from the project list on the left of screen, and drop it on the Frameworks, Libraries, and Embedded Content - Set the seven greenID Mobile related frameworks to be 'Embed & sign':
Customise resources and localised strings (Optional)
The
greenID iOS SDK
zip file also includes a bundle archive (GIDResources.bundle
) which containsgreenID SDK
image resources used within the SDK. This bundle should have been added to your project in the steps above. You can confirm that the bundle is being included in your project by checking (Your Project Target) → Build Phases →Copy Bundle Resources
Optional: You can customise any of the images in theGIDResources.bundle
to match your branding. A complete guide on the process that must be followed can be obtained here:Optional: A
Localizable.strings
file can be created in any parent application that adopts the greenId SDK. This enables the configuration of the default text strings in the iOS SDK.A complete guide on the process that must be followed can be obtained here:
Required project settings
- Go to (Your Project Target)→ General → Deployment Info. Make sure that the Device Orientation supports at least
Portrait
,Landscape Left
andLandscape Right
.
(If you need to restrict parts of your app to portrait mode only, you can do this using- (UIInterfaceOrientationMask)supportedInterfaceOrientations
in your view controllers, rather than restricting the whole app) - At this stage, due to third party frameworks being used, you may not be able to compile our framework with Bitcode enabled. If you experience issues with Bitcode, go to (Your Project Target)→ Build Settings and search for "Bitcode", and set it to "No".
- Some of the third party frameworks require Swift to run. If you want to target phones running iOS versions lower than 13, you will need to embed the Swift standard libraries in your build.
Go to (Your Project Target)→ Build Settings and search for "Swift", and set "Always Embed Swift Standard Libraries" to "Yes".
Required app permissions
To build your app using Xcode 11, you need to provide privacy permissions in your Info.plist file. If your app does not include these values, it might crash as soon as it tries to start the greenID workflow, or key functionality such as the camera being able to take photos may not work.
The app may also be rejected by Apple's review process if these values are not in your Info.plist.
- Open your Info.plist file in Xcode
- Add entries for the following. You can use the raw key or the longer description key when entering these items:
Description key | Raw key | Type | Example value | Note |
---|---|---|---|---|
Privacy - Camera Usage Description | NSCameraUsageDescription | String | "Take photos of your ID, documents and face" | |
Privacy - Location When In Use Usage Description | NSLocationWhenInUseUsageDescription | String | "Record your location when verifying your ID" | The GIDSDK does not have any background services that use the device's location, but Apple insists on having the "NSLocationAlways" key for iOS 11 and above. |
Privacy - Photo Library Usage Description | NSPhotoLibraryUsageDescription | String | "Access your photo library" | This isn't a permission that we will actively use, but some of the frameworks that we link against have methods to use the user's photo library. |
Note about camera permissions: If a user of your app declines the camera privacy permission, greenID will not be able to photograph the user or their ID. If the user later changes the camera permission using the iOS Settings app, the operating system will force a restart of your app if it is running. This is standard behaviour for iOS. You might choose to implement an application delegate method to handle such a restart, and take the user back to the start of the greenID process in your app.
Using the greenID SDK with simulator builds and automated testing
From GIDSDK version 1.22.0 onwards, we also provide a simulator architecture version of the SDK and frameworks. If you need to test minimal functionality on a simulator, rather than physical device, please refer to Using the greenID simulator-enabled iOS frameworks.
Using the SDK
Once greenID SDK has been added to your project using the above steps, you can start using it in your code.
Import <
GIDSDK/GIDSDK.h>
(objective-c) orimport GIDSDK
(Swift) into your view controller.Make your class conform to the
GIDDelegate
protocol to receive the data payload and result of the interaction with the greenID SDK.- Set the relevant configuration parameters (see SDK Configuration Variables) in a dictionary. As a minimum,
accountId,
apiCode, countryCode, mode
andbaseUrl
will be required for instantiating the Framework. The other values will have sensible defaults assigned by the greenID platform. - Create an instance of the greenID SDK
GIDMainViewController
- Push
GIDMainViewController
to your navigation controller.
You can optionally use theprestartCheckForError:
method first, to make sure the SDK is ready to be pushed to your navigation controller. - Add greenID SDK delegate methods to receive the data payload and responses.
- When your app is finished with the greenID workflow, make sure you remove it from the navigation controller using a
popViewControllerAnimated
: orsetViewControllers
: call. This is important, as removingGIDMainViewController
from the navigation stack will deallocate all of the memory associated with the greenID process.
If you look at the iOS sample code, you will see these steps in the ViewController.h
and ViewController.m
file (or ViewController.swift
file).
Querying Details of the Verification Process
The verificationToken
is passed to the mainViewController:didCompleteProcessWithPayload:resultCode:error:
method.
Please see Querying the Outcome of the Verification Process for more information.
Result codes of the verification process (GIDResultCode)
Code - Objective-c | Code - Swift | Meaning |
---|---|---|
GIDResultCodeSuccess |
| The verification process was completed successfully. |
GIDResultCodeCancelled | GIDResultCode.cancelled | The user cancelled the verification process. |
GIDResultCodeBack | GIDResultCode.back | A "back" button was pressed, causing the process to be cancelled. |
GIDResultCodeError | GIDResultCode.error | An internal SDK error has occurred. |
GIDResultCodeNoNetwork | GIDResultCode.noNetwork | No network connection is available, or the active network connection is no longer accessible. |
GIDResultCodeNetworkSecurityError | GIDResultCode.networkSecurityError | An error occurred when trying to verify the SSL certificate used to talk to greenID Mobile server |
GIDResultCodeUserInactivity | GIDResultCode.userInactivity | There was no user activity within the application interface. |
GIDResultCodeResourceBundle | GIDResultCode.resourceBundle | The GIDResource.bundle is missing |
The verificationState
as well as the verificationToken
can be retrieved from the didCompleteProcessWithPayload
delegate method. These verification variables are returned with the payload
dictionary. Note that the verification variables will only be returned if the resultCode is of type GIDResultCodeSuccess
. The verification values would look something like:
{ verificationState = "STATE"; verificationToken = "TOKEN"; }
If the result code is either GIDResultCodeError/GIDResultCode.error or GIDResultCodeNoNetwork/GIDResultCode.noNetwork, your app is responsible for informing the user of the error. From SDK 1.6.0 onwards, a GIDErrorProtocol
object is passed back that you can query to get an idea of what went wrong.
Getting logging and analytics from the SDK
The SDK can pass log events, including some events that can be used for analytics in your app. This is optional - if you don't want your app to receive log messages, then you don't need to implement this code.
Note that if you implement the log delegate, the SDK will stop logging most messages to the standard iOS console, as it will be sending them to your delegate function instead.
To get logging messages:
- First set up a
GIDLoggerDelegate
class that will handle the log messages. This can be the same class that starts the GreenID SDK. - Next, set the log level that the SDK will use. To receive all events, including analytics, use
GIDLogLevelUI
. If you don't set a level, the default isGIDLogLevelInfo
, which is a subset of the logging events. - Tell the SDK which class is acting as the
GIDLoggerDelegate
- Finally, implement the delegate class that will receive the log messages -
sdkDidLogLevel: levelCode: analyticsCode: source: message:
The sample code includes this setup code and an example delegate method.
Sample Code for Objective-C and Swift
Some sample projects, with code for Objective-C and Swift are available.
The sample projects require you to add the latest greenID SDK frameworks and bundles, and add your configuration parameters to the sample code. They will then be able to build and run the greenID Mobile process on a physical device.
Upgrading greenID SDK from a previous version
Home | greenID API | greenID Web | greenID Mobile | greenID Business | greenID Additional Services | Notification of Verification | Admin Panel Guide
If you can't find what you need here, email us at customer.support@gbgplc.com or log a ticket via our portal
On this page
greenID Mobile A-Z
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page: