Integrating LaunchKey with iOS

This document walks you through integrating LaunchKey with iOS apps.

Setting Up the LaunchKey Service

Before integrating LaunchKey with your app, an administrator must complete the following steps:

  1. From an iOS device, launch the Apple store.
  2. Download and install LaunchKey.
  3. Run the LaunchKey app.
  4. On the Device Setup page, do one of the following:
    • If you already have an account, choose I already have an account. On the Existing User Setup page, enter the username associated with the account, and enter a unique name for the device.
    • If you don't already have an account, choose I'm a New LaunchKey User. On the New Account Setup page, Enter a unique user-name. Note this user name as you will need it when configuring the service in the LaunchKey Dashboard. On the Device Name page, enter a nickname for the device.
  5. On the Linking Method page, choose a contact method for linking the device, such as SMS or Email & SMS. Enter the contact information and click Done.
  6. Based on the linking method you chose, you will receive a text message or email with further instructions for completing the device configuration process. Respond as instructed.
  7. Now that the device is configured, you must associate it with a service in the LaunchKey Dashboard. From a browser, open the Dashboard at https://dashboard.launchkey.com/login.
  8. To log in, enter the username that you entered into the app when you linked the device.
  9. On the device, authorize the login.
  10. Now that you are in the Dashboard, click the left navigation button and select Organizations. The All Organizations page appears.
  11. Click the Create New Organization button. The Create New Organization screen appears.
  12. Enter a name for the organization, provide the your name and email address (or name and email address of an admin user). Complete the Create New Organization Screen.
  13. The user whose email you entered will receive a confirmation email. Click the confirmation email to complete creation of the organization.
  14. Back in the Dashboard, open the organization you created. Expand the menu button on the left of the screen and select Organizations, then click the organization.
  15. From within the organization, select the White Label tab.
  16. Click the New White Label Group button to create a new directory. Enter the username for the account that you created on the device, early in this procedure.
  17. Directory details appear. From here, on the General tab, you can see a Mobile SDK Keys list. Capture the Mobile SDK Key. You will need it later when integrating the LaunchKey SDK into your app.
  18. Also on the General tab, under Services, click the NEW APP button. The Create New Service screen appears.
  19. Enter a name and description for the service. Optionally choose an avatar file, read and accept the Terms of Service and click the Create Service button.

You are now ready to integrate the LaunchKey SDK into your mobile apps.

Integrating the iOS SDK into Your App

Follow these steps to integrate the LaunchKey SDK for iOS into your app. This includes examples and instructions for Objective-C and swift.

  1. Download the SDK from https://github.com/iovation/launchkey-ios-whitelabel-sdk/releases

  2. In XCode, add Authenticator.bundle and Authenticator.framework to your project. Make sure that they are visible under Copy Bundle Resources in your target's Build phase. Also ensure that Authenticator.framework appears under Link Binary With Libraries.

  3. Add the following .plist permissions to your project and provide description values for each:

    • NSLocationWhenInUseUsageDescription
    • NSBluetoothPeripheralUsageDescription
    • NSCameraUsageDescription
  4. Import Authenticator.framework to your app delegate or, for Swift projects, your Bridging-Header.h file:

    #import <Authenticator/AuthenticatorManager.h>
    
  5. Initialize the AuthenticatorManager shared client with your Directory SDK Key:

    // Initialize the SDK Manager
    [[AuthenticatorManager sharedClient] initSDK:@"<Directory_SDK_Key>"];
    
  6. To enable users to link their devices, specify a linking mechanism. You can enable either QR code scanning by passing a YES or the ability to manually enter their linking code by passing NO.

    Objective-C:

    [[AuthenticatorManager sharedClient] showLinkingView:self.navigationController withCamera\:YES withLinked\:^{
        // Success block
        // End-user has been successfully linked
    } withFailure:^(NSString *errorMessage, NSString *errorCode) {
        // Failure block
        // Check error
    }];
    

    Swift:

    AuthenticatorManager.sharedClient().showLinkingView(self.navigationController, withCamera: true, withLinked: {() in
        // Success block
        // End-user has been successfully linked
    }, withFailure:{(errorMessage, errorCode) in
        // Failure block
        // Check error
    })
    
  7. To create a view where users can view auth requests, first import the AuthRequestViewController.h file:

    #import <Authenticator/AuthRequestViewController.h>
    

    Then, initialize AuthRequestViewController and define a Container view where you can embed the auth request view.

    Objective-C:

    AuthRequestViewController *requestChildView = [[AuthRequestViewController alloc] initWithParentView:self];
    [self addChildViewController:requestChildView];
    [self.containerView addSubview:requestChildView.view];
    [requestChildView didMoveToParentViewController:self];
    
    // Check For Pending Auth Request
    [authRequestChildView checkForPendingAuthRequest:self.navigationController withCompletion:^(NSString *message, NSError *error)
    {
        if(error != nil)
        {
            // Check error
        }
        else
        {
            // Check message to see if response to auth request was successful or if there are no pending auth requests
            NSLog(@"Message: %@", message);
        }
    }];
    

    Swift:

    var authRequestView:AuthRequestViewController!
    authRequestView = AuthRequestViewController.init(parentView: self)
    self.addChildViewController(authRequestView)
    containerView.addSubview(authRequestView.view)
    authRequestView.didMove(toParentViewController: self)
    
    // Check For Pending Auth Request
    authRequestView.check(forPendingAuthRequest: self.navigationController, withCompletion: { (message,error) in
        if((error) != nil)
        {
            // Check error
        }
        else
        {
            // Check message to see if response to auth request was successful or if there are no pending auth requests
        print("\(message)")
        }
    })
    
  8. End-users can choose their own security factors. Services can be set to require users to set a minimum number of factors. Implement the following to enable users to use the Security Factors view and choose their security factors.

    Objective-C:

    [[AuthenticatorManager sharedClient] showSecurityViewWithNavController:self.navigationController withUnLinked:^{
    }];
    

    Swift:

    AuthenticatorManager.sharedClient().showSecurityView(withNavController: self.navigationController, withUnLinked: {() in
    })
    
  9. Implement the IOADevice object to unlink either the current device or a remote device.

    Objective-C:

    [[AuthenticatorManager sharedClient] unlinkDevice:nil withCompletion:^(NSError *error){
        if(error != nil)
        {
            // Check error
        }
        else
        {
            // Device has been successfully unlinked
        }
    }];
    

    Swift:

    AuthenticatorManager.sharedClient().unlinkDevice(nil, withCompletion: { (error) in
    if((error) != nil)
        {
            // Check error
        }
        else
        {
            // Device has been successfully unlinked
        }
    })
    

This completes the core integration. Continue on to the next section for advanced integration options.

Advanced Integration Options

Now that the LaunchKey SDK for iOS is integrated and the basics are working, let's move on to more advanced integration options. We'll start by reviewing the technical components that make up advanced LaunchKey integration.

Activation Delay (v3.0.4 and up)

The Authenticator SDK allows you to set an activation delay for passive security factors, such as geo-fences or Bluetooth proximity devices. This is the time it takes for the SDK to add or remove a passive factor. The delay also applies when an end-user toggles the verification setting for a security factor, which changes how the factor is verified during auth requests, for example only when required, or always.

You can set the delay for a range of time between 0 seconds to 24 hours. Provide the value in seconds, for example set it to 864000 to for a delay of 24 hours.

The following examples set the delay to 24 hours.

Objective-C:

[[AuthenticatorConfigurator sharedConfig] setActivationDelayProximity:86400];

[[AuthenticatorConfigurator sharedConfig] setActivationDelayGeofence:86400];

Swift:

AuthenticatorConfigurator.sharedConfig().setActivationDelayProximity(86400)

AuthenticatorConfigurator.sharedConfig().setActivationDelayGeofence(86400)

Warning

Setting the activation delay to 0 can potentially allow anyone to bypass passive security factors. They can do this by adding new, unintended passive factors and setting the verification toggle to only verify when required. If the user then immediately attempts to authenticate, the new passive factor will not be verified. For this reason, we strongly suggest setting the value to a minimum of ten minutes / 600 seconds.

AuthenticationManager Overview

The AuthenticationManager enables you to implement several additional features:

  • Customizing device linking
  • Verifying and listing the security factors that are currently enabled
  • Displaying a list of all linked devices
  • Managing sessions
  • Setting key pair sizes
  • Listening to events via NSNotificationCenter

Customizing Device Linking

You can customize your implementation of device linking. To do this, pass a valid linking code to the following call. Include a device name if necessary, or pass nil as the device name and the SDK will populate the device name based on the current OS device name. If you want to enable the end-user to override the device name, set deviceNameOverride to YES.

Objective-C:

NSString *qrCode = @"ABCD123";
BOOL deviceNameOverride = YES;


[[AuthenticatorManager sharedClient] linkUser:qrCode withDeviceName:deviceName deviceNameOverride:deviceNameOverride withCompletion:^(NSError *error)
{
    if(error!=nil)
    {
        // Check error
    }
    else
    {
        // End-user has successfully linked
    }
}];

Swift:

let qrCode = "ABCD123"


AuthenticatorManager.sharedClient().linkUser(qrCode, withDeviceName:nil, deviceNameOverride:true, withCompletion: { (error) in
    if((error) != nil)
    {
        // Check error
    }
    else
    {
        // End-user has successfully linked
    }
})

Then to determine whether an end-user has been successfully linked, call isAccountActive.

Objective-C:

if([[AuthenticatorManager sharedClient] isAccountActive])
{
    // End-user's device is linked
}

Swift:

if(AuthenticatorManager.sharedClient().isAccountActive())
{
    // End-user's device is linked
}

Verifying Current security Factors

Use securityFactorArray to return an NSArray to list out the factors, types, and whether they are active.

Objective-C:

NSArray *securityFactorArray = [[AuthenticatorManager sharedClient] getSecurityInfo];

Swift:

let securityFactorArray = AuthenticatorManager.sharedClient().getSecurityInfo()

Displaying Linked Devices

Use DevicesViewController to manage device actions. The Authenticator SDK provides a default view to display linked devices and provides methods that you can use to implement a custom view.

First, import DevicesViewController.h and IOADevice.h:

#import <Authenticator/DevicesViewController.h>
#import <Authenticator/IOADevice.h>

Then, initialize DevicesViewController and display the default view in a container view.

Objective-C:

DevicesViewController *devicesChildView = [[DevicesViewController alloc] initWithParentView:self];

[self addChildViewController:devicesChildView];
[self.containerView addSubview:devicesChildView.view];
[devicesChildView didMoveToParentViewController:self];

Swift:

var devicesChildView:DevicesViewController!
devicesChildView = DevicesViewController.init(parentView: self)

self.addChildViewController(devicesChildView)
containerView.addSubview(devicesChildView.view)
devicesChildView.didMove(toParentViewController: self)

Use the following methods to perform device-related tasks.

Objective-C:

    DevicesViewController *devicesView;
NSArray *devicesArray;


devicesView = [[DevicesViewController alloc] initWithParentView:self];


// Get the current IOADevice object
IOADevice *currentDevice = [devicesView currentDevice];
NSLog(@"current device name = %@", currentDevice.name);


// Call getDevices to get a NSArray of IOADevice objects
[devicesView getDevices:^(NSArray* array, NSError *error)
{
    if(error)
    {
        // Check error
        NSLog(@"error: %@", error);
    }
    else
    {
        devicesArray = array;
        for(IOADevice *deviceObject in devicesArray)
        {
            NSLog(@"device name: %@", deviceObject.name);
            NSLog(@"device status: %lu", (unsigned long)deviceObject.status);
            NSLog(@"device uuid: %@", deviceObject.UUID);
            NSLog(@"device type: %@", deviceObject.type);
        }
    }
}];

Swift:

var devicesArray = [IOADevice]()
var devicesChildView:DevicesViewController!
devicesChildView = DevicesViewController.init(parentView: self)

// Call getDevices to get a NSArray of IOADevice objects
devicesChildView.getDevices { (array, error) in
    if((error) != nil)
    {
        // Check error
        print("\(error)")
    }
    else
    {
        devicesArray = array!
        for item in devicesArray
        {
            let deviceObject = item
            print("device name: \(deviceObject.name)")
        }
    }
}

Managing Sessions

Use SessionsViewController to manage session-related tasks. The Authenticator SDK provides a default view to display sessions and provides methods that you can use to implement a custom view of Sessions as well.

First, import SessionsViewController.h and IOASession.h:

#import <Authenticator/SessionsViewController.h>
#import <Authenticator/IOASession.h>

Then, initialize SessionsViewController and display the default view in a container view.

Objective-C:

SessionsViewController *sessionsChildView = [[SessionsViewController alloc] initWithParentView:self];

[self addChildViewController:sessionsChildView];
[self.containerView addSubview:sessionsChildView.view];
[sessionsChildView didMoveToParentViewController:self];

Swift:

var sessionsChildView:SessionsViewController!
sessionsChildView = SessionsViewController.init(parentView: self)

self.addChildViewController(sessionsChildView)
containerView.addSubview(sessionsChildView.view)
sessionsChildView.didMove(toParentViewController: self)

You can use the following methods to manage session-related tasks and create a custom Sessions View if needed. Call -getSessions to get a NSArray of all the currently active IOASession objects. Each IOASession object contains four properties so that you can easily create a custom designed view of Sessions: serviceName, serviceID, serviceIcon, and dateCreated.

Objective-C:

SessionsViewController *sessionsView;
NSArray *sessionsArray;
sessionsView = [[SessionsViewController alloc] initWithParentView:self];

// Call getSessions to get a NSArray of all the IOASession objects
[sessionsView getSessions:^(NSArray* array, NSError *error)
{
    if(error)
    {
        NSLog(@"error: %@", error);
    }
    else
    {
        sessionsArray = array;
        for(IOASession *sessionObject in sessionsArray)
        NSLog(@"session name: %@", sessionObject.serviceName);
    }
}];


// End a specific session
IOASession *sessionObject = [sessionsArray objectAtIndex:indexPath.row];
[sessionsView clearSession:sessionObject];


// End all sessions
[sessionsView endAllSessions:^(NSError *error)
{
    if(error != nil)
    {
        // Check error
        NSLog(@"Error: %@", error);
    }
    else
    {
        // All sessions have been successfully cleared
    }
}];

Swift:

var sessionsArray = [IOASession]()
var sessionsView:SessionsViewController!


// Call getSessions to get a NSArray of all the IOASessions objects
sessionsView.getSessions { (array, error) in

    if((error) != nil)
    {
        // Check error
        print("\(error)")
    }
    else
    {
        sessionsArray = array!
        for item in sessionsArray
        {
            let sessionObject = item
            print("session name: \(sessionObject.serviceName)")
        }
    }
}


// End a specific session
sessionsView.clear(sessionsArray[row])

// End All sessions
    sessionsView.endAllSessions{(error) in
    if((error) != nil)
    {
        // Check error
        print("\(error)")
    }
    else
    {
        // All sessions have been successfully cleared
    }
}

Setting Key Pair Size

Linking a device creates a key pair. You can use AuthenticatorManager to set its size. The size can be between 2048-4096 bits; if the value is outside of the range, it is set to the nearest valid value, or it will be invalid. By default, if you do not set a key pair size, it is 4096. There are constants available in AuthenticatorManager for common key pair sizes. NOTE Set the key pair size before initializing the SDK.

Objective-C:

[[AuthenticatorConfigurator sharedConfig] setKeyPairSize:keypair_maximum];

Swift:

AuthenticatorConfigurator.sharedConfig().setKeyPairSize(keypair_maximum)

Listening To Events via NSNotificationCenter

There are specific events that you can add observers to so that you can implement your own UI. Here are a list of observers you can add:

requestReceived: Add an observer for requestReceived to be notified when an auth request has been received. You can call -checkForPendingAuthRequest to bring up the auth request once the notification has been broadcasted.

deviceUnlinked: Add an observer for deviceUnlinked to be notified when the device has been unlinked successfully or when the API returns an error indicating the device is unlinked.

requestApproved: Add an observer for requestApproved to be notified when an auth request has been approved.

requestDenied: Add an observer for requestDenied to be notified when an auth request has been denied.

Customizing the User Interface

Overview

You can customize a number of user interface (UI) elements in the Security and Auth Request views by setting colors using the UIAppearance proxy settings. The Authenticator has subclassed some UI elements so that they can be modified via proxy UIAppearance proxy.

Getting Started

In order to customize UI elements, import the following:

#import <Authenticator/PinCodeButton.h>
#import <Authenticator/CircleCodeImageView.h>
#import <Authenticator/AuthenticatorButton.h>
#import <Authenticator/AuthorizationSliderButton.h>
#import <Authenticator/AuthorizationSlider.h>
#import <Authenticator/SecurityFactorTableViewCell.h>
#import <Authenticator/AuthRequestContainer.h>
#import <Authenticator/IOALabel.h> // Available in v3.0.5 and up

UI Customization Examples

These examples walk you through the customizable elements and how you can set them in both Objective-C and Swift.

If you will set custom fonts, determine whether the fonts are supported by XCode, then:

  • If they are supported, pass the font names as NSSString values to the setFont call
  • If not, import the font files to your project, include them in the targets, and add them to the .plist under a new row called Fonts provided by application. In this row, include all of the font names in an array.

Objective-C:

// Include Info buttons in the Security screens
[[AuthenticatorConfigurator sharedConfig] enableInfo:YES];

// Include table headers
[[AuthenticatorConfigurator sharedConfig] enableHeaderViews:YES];

// Enable notification prompt if disabled
[[AuthenticatorConfigurator sharedConfig] enableNotificationPrompt:YES];

// Disable Back Bar Button Item from being shown (available in v3.0.5 and up)
[[AuthenticatorConfigurator sharedConfig] enableBackBarButtonItem:NO];

// Disable view controller animation when transitioning (available in v3.0.5 and up)
[[AuthenticatorConfigurator sharedConfig] enableViewControllerTransitionAnimation:NO];

// Set custom font
[[AuthenticatorConfigurator sharedConfig] setFont:@"Roboto"];

UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];

// Set bar tint color of navigation bar
[navigationBarAppearance setBarTintColor:[UIColor colorWithRed:(245.0/255.0) green:(245.0/255.0) blue:(245.0/255.0) alpha:1.0]];

// Set title text color of navigation bar
NSDictionary *textAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName, nil];
[navigationBarAppearance setTitleTextAttributes:textAttributes];

// Set appearance for normal bar button items
NSDictionary *textAttributes2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:(61.0/255.0) green:(160.0/255.0) blue:(183.0/255.0) alpha:1.0], NSForegroundColorAttributeName, nil];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
setTitleTextAttributes:textAttributes2
forState:UIControlStateNormal];

// Set tint color of UISwitch
[[UISwitch appearance] setOnTintColor:[UIColor colorWithRed:(61.0/255.0) green:(160.0/255.0) blue:(183.0/255.0) alpha:1.0]];

// Set tint color of bar button items
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor colorWithRed:(61.0/255.0) green:(160.0/255.0) blue:(183.0/255.0) alpha:1.0]];

// Set tint color of Navigation Bar
[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:(61.0/255.0) green:(160.0/255.0) blue:(183.0/255.0) alpha:1.0]];

// Set text color labels contained in table views
[[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil] setTextColor:[UIColor blackColor]];

// Set text color of labels in Security View and Add Bluetooth Proximity View (available in v3.0.5 and up)
[IOALabel appearance].textColor = [UIColor whiteColor];

// Set UIAppearance colors for PIN Code
[[PinCodeButton appearance] setTitleColor:[UIColor colorWithRed:(61.0/255.0) green:(160.0/255.0) blue:(183.0/255.0) alpha:1.0] forState:UIControlStateNormal];
[PinCodeButton appearance].highlihgtedStateColor = [UIColor whiteColor];
[PinCodeButton appearance].backgroundColor = [UIColor colorWithRed:(245.0/255.0) green:(245.0/255.0) blue:(245.0/255.0) alpha:1.0];
[[PinCodeButton appearance] setPinCodeButtonAsCircle:YES];
// Set color of letters in PIN Code (available in v3.0.5 and up)
[PinCodeButton appearance].lettersColor = [UIColor blackColor];

// Set UIAppearance colors for the AuthenticatorButton
[[AuthenticatorButton appearance] setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[AuthenticatorButton appearance].backgroundColor = [UIColor colorWithRed:(0.0/255.0) green:(188.0/255.0) blue:(212.0/255.0) alpha:1.0];

// Set UIAppearance colors for Circle Code
[CircleCodeImageView appearance].defaultColor = [UIColor darkGrayColor];
[CircleCodeImageView appearance].highlightColor = [UIColor colorWithRed:(61.0/255.0) green:(160.0/255.0) blue:(183.0/255.0) alpha:1.0];

// Set UIAppearance colors for the Authorization slider
[AuthorizationSliderButton appearance].backgroundColor = [UIColor grayColor];
[AuthorizationSliderButton appearance].highlihgtedStateColor = [UIColor lightGrayColor];
[[AuthorizationSliderButton appearance] setTintColor:[UIColor whiteColor]];
[AuthorizationSlider appearance].topColor = [UIColor whiteColor];
[AuthorizationSlider appearance].bottomColor = [UIColor darkGrayColor];

// Set background color of controls
[[AuthenticatorConfigurator sharedConfig] setControlsBackgroundColor:[UIColor clearColor]];

// Set visibility of images for security factors
[[AuthenticatorConfigurator sharedConfig] enableSecurityFactorImages:YES];

// Set color of UITableView separator color
[[UITableView appearance] setSeparatorColor:[UIColor clearColor]];

// Set custom images for security factors
[SecurityFactorTableViewCell appearance].imagePINCodeFactor = [UIImage imageNamed:@"Image1"];
[SecurityFactorTableViewCell appearance].imageCircleCodeFactor = [UIImage imageNamed:@"Image2"];
[SecurityFactorTableViewCell appearance].imageBluetoothFactor = [UIImage imageNamed:@"Image3"];
[SecurityFactorTableViewCell appearance].imageGeofencingFactor = [UIImage imageNamed:@"Image4"];
[SecurityFactorTableViewCell appearance].imageFingerprintFactor = [UIImage imageNamed:@"Image5"];

// Set custom images for images in auth requests
[AuthRequestContainer appearance].imageAuthRequestGeofence = [UIImage imageNamed:@"Image1"];
[AuthRequestContainer appearance].imageAuthRequestBluetooth = [UIImage imageNamed:@"Image2"];
[AuthRequestContainer appearance].imageAuthRequestFingerprint = [UIImage imageNamed:@"Image3"];

Swift:

// Include Info button
AuthenticatorConfigurator.sharedConfig().enableInfo(false)

// Include table headers
AuthenticatorConfigurator.sharedConfig().enableHeaderViews(true)

// Set custom font
AuthenticatorConfigurator.sharedConfig().setFont("Roboto")

// Enable notification prompt if disabled
AuthenticatorConfigurator.sharedConfig().enableNotificationPrompt(true)

// Disable Back Bar Button Item from being shown (available in v3.0.5 and up)
AuthenticatorConfigurator.sharedConfig().enableBackBarButtonItem(false)

// Disable view controller animation when transitioning (available in v3.0.5 and up)
AuthenticatorConfigurator.sharedConfig().enableViewControllerTransitionAnimation(false)

// Set color for Navigation bar
UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255, green: 150.0/255, blue: 136.0/255, alpha: 1.0)
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]

// Set tint color of UISwitch
UISwitch.appearance().onTintColor = UIColor(red: 255.0/255, green: 64.0/255, blue: 129.0/255, alpha: 1.0)

// Set tint color of bar button items
UIBarButtonItem.appearance().tintColor = UIColor.white

// Set tint color of Navigation Bar
UINavigationBar.appearance().tintColor = UIColor.white

// Set text color of labels in Security View and Add Bluetooth Proximity View (available in v3.0.5 and up)
IOALabel.appearance().textColor = UIColor.white

// Set UIAppearance colors for PIN Code
PinCodeButton.appearance().setTitleColor(UIColor(red: 0/255, green: 188/255, blue: 212/255, alpha: 1.0), for: .normal)
PinCodeButton.appearance().highlihgtedStateColor = UIColor.white
PinCodeButton.appearance().backgroundColor = UIColor(red: 232.0/255, green: 232.0/255, blue: 232.0/255, alpha: 1.0)
PinCodeButton.appearance().setPinCodeButtonAsCircle(true)
// Set color of letters in PIN Code (available in v3.0.5 and up)
PinCodeButton.appearance().lettersColor = UIColor.black


// Set UIAppearance colors for AuthenticatorButton
AuthenticatorButton.appearance().setTitleColor(UIColor.white, for: .normal)
AuthenticatorButton.appearance().backgroundColor = UIColor(red: 255/255, green: 64/255, blue: 129/255, alpha: 1.0)

// Set UIAppearance colors for Circle Code
CircleCodeImageView.appearance().defaultColor = UIColor.gray
CircleCodeImageView.appearance().highlightColor = UIColor.darkGray

// Set UIAppearance colors for the Authorization slider
AuthorizationSliderButton.appearance().backgroundColor = UIColor.gray
AuthorizationSliderButton.appearance().highlihgtedStateColor = UIColor.lightGray
AuthorizationSliderButton.appearance().tintColor = UIColor.white
AuthorizationSlider.appearance().topColor = UIColor.white
AuthorizationSlider.appearance().bottomColor = UIColor.darkGray

// Set backgrund of controls
AuthenticatorConfigurator.sharedConfig().setControlsBackgroundColor(UIColor.clear)

// Set visibility of images for security factors
AuthenticatorConfigurator.sharedConfig().enableSecurityFactorImages(true)

// Set color of UITableView separator color
UITableView.appearance().separatorColor = UIColor.clear

// Set custom images for security factors
SecurityFactorTableViewCell.appearance().imagePINCodeFactor = UIImage(named:"Image1")
SecurityFactorTableViewCell.appearance().imageCircleCodeFactor = UIImage(named:"Image2")
SecurityFactorTableViewCell.appearance().imageBluetoothFactor = UIImage(named:"Image3")
SecurityFactorTableViewCell.appearance().imageGeofencingFactor = UIImage(named:"Image4")
SecurityFactorTableViewCell.appearance().imageFingerprintFactor = UIImage(named:"Image5")

// Set custom images for images in Auth Request flow
AuthRequestContainer.appearance().imageAuthRequestGeofence = UIImage(named:"Image1")
AuthRequestContainer.appearance().imageAuthRequestBluetooth = UIImage(named:"Image2")
AuthRequestContainer.appearance().imageAuthRequestFingerprint = UIImage(named:"Image3")

// To set background color
self.window?.backgroundColor = UIColor(red: 0/255, green: 121/255, blue: 107/255, alpha: 1.0)

Adding Push Notifications to Your Integration

Overview

iovation recommends adding push notifications to your integrations in order to provide a better experience for end users. We also recommend providing a mechanism to manually review notifications, because push notifications depend on many interrelated systems to work, such as mobile carrier availability and Google performance.

At a high level, the setup steps include:

  1. Register for an Apple Push Notification token.
  2. Register the token with the SDK.
  3. Obtain an Apple Push Notification Certificate.
  4. Set up interception of push notifications.

Registering for an Apple Push Notification Token

To identify a device and to receive push notifications from the LaunchKey platform, you must register for an Apply Push Notification token:

Objective-C:

[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];

Swift:

let center = UNUserNotificationCenter.current()
center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
}
application.registerForRemoteNotifications()

Registering the Device Token

You must register the device token with the Authenticator SDK using the didRegisterForRemoteNotificationsWithDeviceToken function in the AppDelegate callback.

Objective-C:

[[AuthenticatorManager sharedClient] setNotificationToken:deviceToken];

Swift:

AuthenticatorManager.sharedClient().setNotificationToken(deviceToken)

Obtaining an Apple Push Notification Certification

You must obtain an Apple Push Notification Certification before the LaunchKey platform can send push notifications to your mobile app. These instructions assume that you have already set up push notifications for your app. To do this:

  1. Log in to the Apple Developer Portal at: https://developer.apple.com
  2. Click the Certifications, IDs & Profiles section.
  3. Under Certificates, locate the Production Push Notification certificate that you create for your app (the same certificate that you use in production now for your app). Download the certificate.
  4. Double-click the local certificate file to add it to your keychain's Certificate section.
  5. Open Keychain Access.
  6. Select Certificates and click the arrow beside the certificate you just downloaded. This displays the associated key. Select both the certificate and key, right-click and choose Export 2 items.
  7. Save the certificate with a .p12 file extension and leave the password field empty.
  8. Log in to LaunchKey Dashboard at https://dashboard.launchkey.com/login.
  9. Click Organizations and select your organization. Click the White Label tab. Select the White Label Directory for which you want to authorize push notifications.
  10. Select the Push Notifications tab and upload your certification under the iOS section.

Setting Up Interception of Push Notifications

In order to intercept push notifications, use the didReceiveRemoteNotification callback in the AppDelegate. Pass the userInfo to the following call and add the requestReceived observer.

Objective-C:

[[AuthenticatorManager sharedClient] handleRemoteNotification:userInfo];

Swift:

AuthenticatorManager.sharedClient().handleRemoteNotification(userInfo)

User Contributed

LaunchKey links to user contributed code as a resource to its community. LaunchKey does not in any way guarantee or warrant the quality and security of these code bases. User contributed code is supported by the creators. If you do find a link from the site to user contributed code that is malicious or inappropriate in any way, please report that link to LaunchKey immediately and we will investigate the claim. Submit any issue to LaunchKey support at https://launchkey.com./support. ×