Okay LogoOkay Logo

Get started with iOS

Use our SDK for iOS apps

Get started with iOS
Download iOS SDK
1. Installation
1.1 CocoaPods

For PSA, use the following entry in your Podfile:


pod 'PSASDK', '~> 1.0.6'

Then run pod install in any file you'd like to use Moya in.

Don't forget to import the framework! 

Manually

  1. Open the project’s General Tab.
  2. Add PSA and PSACommon frameworks to embedded binaries section.

zip with PSA framework

zip with PSACommon framework

2. Usage

The SDK works only on real devices.

To use PSA 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 Enroll

When you enable push notifications and receive the device token, you can now register it in SDK by:

PSA.updateDeviceToken(deviceToken: String!)

Now you’re ready for enrolling.

if PSA.isReadyForEnrollment() { PSA.startEnrollment(withHost: host, installationId: installationId, pubPssBase64: pubPssBase64) { status in //Handle enrollment status } }

installationId and pubPssBase64 should be the same on both app and server. You can request these parameters from Protectoria Secure Server.

installationId is used for identifier application.

pubPssBase64 is a key for encryption request headers.

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

To check if the app is already enrolled, use this call:

PSA.isEnrolled() -> Bool

2.2 Authorization

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 check if authorization is available with:

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?) { isCancelled, status in

//Handle authorisation result

}

PSATheme describes colors and fonts on authorization 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 authorization screens style, you can set dictionary with next keys:


Next pictures will help you to understand which key you need


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

4.1 Mobile Client Settings

To use the Okay SDK, you need installationId and pubPss key. They are issued for every version.

iOS:
PSMP Version: 1.0.3
Installation: 9980

Public PSS Keys

Note: Keys are encoded in PKCS#1 format.


Installation 9980

-----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEAxgyacF1NNWTA6rzCrtK60se9fVpTPe3HiDjHB7MybJvNdJZIgZbE 9k3gQ6cdEYgTOSG823hkJCVHZrcf0/AK7G8Xf/rjhWxccOEXFTg4TQwmhbwys+sY /DmGR8nytlNVbha1DV/qOGcqAkmn9SrqW76KK+EdQFpbiOzw7RRWZuizwY3BqRfQ Rokr0UBJrJrizbT9ZxiVqGBwUDBQrSpsj3RUuoj90py1E88ExyaHui+jbXNITaPB UFJjbas5OOnSLVz6GrBPOD+x0HozAoYuBdoztPRxpjoNIYvgJ72wZ3kOAVPAFb48 UROL7sqK2P/jwhdd02p/MDBZpMl/+BG+qQIDAQAB -----END RSA PUBLIC KEY-----

Installation 9990

-----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEAxgyacF1NNWTA6rzCrtK60se9fVpTPe3HiDjHB7MybJvNdJZIgZbE 9k3gQ6cdEYgTOSG823hkJCVHZrcf0/AK7G8Xf/rjhWxccOEXFTg4TQwmhbwys+sY /DmGR8nytlNVbha1DV/qOGcqAkmn9SrqW76KK+EdQFpbiOzw7RRWZuizwY3BqRfQ Rokr0UBJrJrizbT9ZxiVqGBwUDBQrSpsj3RUuoj90py1E88ExyaHui+jbXNITaPB UFJjbas5OOnSLVz6GrBPOD+x0HozAoYuBdoztPRxpjoNIYvgJ72wZ3kOAVPAFb48 UROL7sqK2P/jwhdd02p/MDBZpMl/+BG+qQIDAQAB -----END RSA PUBLIC KEY-----

4.2 AuthData Types

The following types of user answers that may come from the mobile application:

  • Code:

    • 101

      • Value:

        • CANCEL

    • 102

      • Value:

        • PIN

    • 103

      • Value:

        • OK