Okay LogoOkay Logo

Get started with iOS

Use our SDK for iOS apps

Get started with iOS
1. Installation

Our solution is based on server-side integration and SDK which has to be done on the mobile-side. It uses Apple push notification services to wake up the SDK when a transaction should be approved using SCA. 

If you’d like to test out the Okay solution, we strongly recommend you to try out our application on play store or app store, which already has the Okay SDK integrated. You can also take a look at our guide, which explains how to Integrate the Okay app with your service. If you’d like to use our SDK with your iOS application, we also recommend you schedule a demo with us to help guide you through the integration process.


Kindly note, our SDK requires that your application can receive push notifications and is properly set up for the Okay Secure Server. If you have any questions or issues with the integration process, feel free to contact us at developer@okaythis.com.

1.1 Swift Package Manager

Open Xcode then navigate to File -> Swift Packages -> Add Package Dependency. Enter depository URL as https://github.com/Okaythis/PSAiOS. Use “Next Major” as your default version rule.


1.2 CocoaPods

To add the Okay SDK dependency to your application, add the following entry to your Podfile:

pod 'PSASDK', '~> 1.1.5'

Then run the pod install command in your terminal.

Manually

  1. Open the project’s general tab.
  2. Add PSA, PSACommon and DefaultPsaUi frameworks to your embedded binaries section in Xcode.

Click the links below to download the required zipped frameworks.

zip with PSA framework

zip with PSACommon framework

zip with DefaultPsaUi

Please don't forget to import the framework in your application with import PSA.



2. Usage

The SDK is compatible with both devices and simulators, but multi-factor authentication is only available on real devices because of the push notification services requirement.

In order to use the SDK, you should enable push notifications for your app. In this example, we will use a test endpoint that will send push notifications after clicking the button.


2.1 Enrol

When you have got push notifications enabled and the device push notification token is received on the device, you can register it with Okay Secure SDK with the following method call:

PSA.updateDeviceToken(deviceToken: String!)

Now you’re ready for enrolling.

Enrolment Sample Code

if PSA.isReadyForEnrollment() {

PSA.startEnrollment(withHost: “https://www.examplehost.com”,

invisibly: true,

installationId: installationIdString,

resourceProvider: nil,

pubPssBase64: pubPssBase64String) { status in

// Handle enrollment status

}

}

Where:

  • host: should be the link to Okay Secure Server address.
  • Invisibly: is a parameter that describes whether the enrolment screen should be shown or not
  • installationId: is used as an application identifier
  • resourceProvider:  object for passing additional data into the SDK
  • pubPssBase64: is a key used for request headers encryption. installationId and
    pubPssBase64: should be the same on both the app and the server. 
  • status: parameter to be passed in closure describes enrolment status

If enrollment was completed successfully, then you’re ready to receive notifications.

To check if the app is already enrolled, use the following method:

PSA.isEnrolled() -> Bool


2.2 Authorisation

For authorization you need the next parameter from push notification:

let pss = notification.request.content.userInfo["pss"] as? [String: Any], let data = pss["data"] as? [String: Any], let sessionId = data["sessionId"] as? NSNumber

Now you can check if authorisation with Okay SDK is available in the application by calling the following method:

PSA.isReadyForAuthorization() -> Bool

We’re almost done, after your app receives a push notification, parse the sessionId from it with this call:

PSA.startAuthorization(with: PSATheme?,

sessionId: NSNumber?,

resourceProvider: ResourceProvider?,

loaderViewController: UIViewController?, completion: (Bool, PSASharedStatuses, TransactionInfo?) -> Void)

For example:

PSA.startAuthorization(with: nil,

sessionId: 1234,

resourceProvider: nil,

loaderViewController: nil) {

isCancelled, status, transactionInfo in

// Handling Authorisation result

}

Where 

  • psaTheme: object describes colours and fonts on the authorisation screen
  • sessionId: number is a value, parsed from the received push notification
  • resourceProvider: - object for passing additional data into the SDK
  • loaderViewController: - UIViewController object to be shown before the authorisation screen during the communication process with the server
  • isCancelled: closure parameter describes if authorisation was cancelled or confirmed
  • status: parameter describes authorisation operation completion status
  • transactionInfo: is an object, containing the completed authorisation operation result

Use the following installationId and pubPss key:

installationId: 9980

pubPss: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxgyacF1NNWTA6rzCrtK60se9fVpTPe3HiDjHB7MybJvNdJZIgZbE9k3gQ6cdEYgTOSG823hkJCVHZrcf0/AK7G8Xf/rjhWxccOEXFTg4TQwmhbwys+sY/DmGR8nytlNVbha1DV/qOGcqAkmn9SrqW76KK+EdQFpbiOzw7RRWZuizwY3BqRfQRokr0UBJrJrizbT9ZxiVqGBwUDBQrSpsj3RUuoj90py1E88ExyaHui+jbXNITaPBUFJjbas5OOnSLVz6GrBPOD+x0HozAoYuBdoztPRxpjoNIYvgJ72wZ3kOAVPAFb48UROL7sqK2P/jwhdd02p/MDBZpMl/+BG+qQIDAQAB

PSATheme describes colors and fonts on authorisation screen.

3. PSA Theme

PSATheme is a class that describes the style of authorization screens.

@interface PSATheme : NSObject <NSCoding> @property (strong, readonly, nullable) UIImage *logo; @property (copy, readonly, nullable) NSString *title; - (instancetype)initWithTitle:(nullable NSString *)title; - (void)setResponseDictionary:(nullable NSDictionary<NSString *, id> *)responseDictionary; - (UIColor *)getColorForKey:(nullable NSString *)key; @end

To change the authorisation screens style or appearance, you can set a dictionary with the following keys:

The following images below will help you understand which key you need.

Could you okay this? Helper diagram
It's Okay, Helper diagram
 That's Okay, helper diagram
4. Client Settings

4.1 Device Liveliness

The Okay secure SDK allows the backend to retrieve information about a user’s device, such as:

  • Push notification settings.
  • Biometric sensor availability or Biometric identification capability on the user device.

When the user device information is requested, the app receives push notification containing session type with value 30. Session type can be extracted as shown in the sample code below:

func fetchSessionType(fromNotification notification: UNNotification) -> Int? {

guard let pss = notification.request.content.userInfo["pss"] as? [String: Any] else {

return nil

}

return pss[“type”] as? Int

}

After retrieving session type use the following method to send the device settings to the server:

PSA.sendDeviceLivelinessSettings(completion: (PSASharedStatuses) -> Void)

The passed completion handler receives the session completion result.