iOS PingOne Mobile SDK API


Overview

The PingOne Mobile SDK provides the ability to integrate PingOne MFA functionality into your mobile applications.

Further details on how to integrate the PingOne Mobile SDK into your iOS applications are provided in the mobile SDK package. Download the mobile SDK package from https://github.com/pingidentity/pingone-customers-mobile-sdk.

PingOne Mobile SDK API for iOS

The PingOne Mobile SDK for iOS includes the following public interface:

//  PingOne
//
//  Created by Ping Identity on 3/12/19.
//  Copyright © 2019 Ping Identity. All rights reserved.
//

//! Project version number for PingOne.
public var PingOneVersionNumber: Double
@objc public enum ErrorCode : NSInteger {

    /// Internal Error.
    case internalError

    /// Device token was missing and is required to complete this action.
    case deviceTokenIsMissing

    /// Remote notification isn't from PingOne.
    case unrecognizedRemoteNotification

    /// There was a server error.
    case serverError

    /// There was a problem with the network.
    case noConnectivity

    /// There was a problem with the pairing key.
    case pairingKey

    /// There was a problem with the bundle id.
    case bundleId
}

/// A Notification Object represents an authentication request via remote notification. It can be approved or denied.
@objc public class NotificationObject : NSObject {

    /// Type that describes the purpose of the notification.
    @objc public enum NotificationType : NSInteger {

        /// Notification was not recognized. 
        case none

        /// Notification process has finished. No further action is required.
        case done

        /// Authentication notification that should be presented to the user and followed with the `approve` or `deny` method.
        case authentication
    }

    @objc public let notificationType: PingOne.NotificationObject.NotificationType

    /// Approve authentication
    ///
    /// - Parameter completionHandler: Will return NSError in case of an error.
    @objc final public func approve(completionHandler: @escaping (NSError?) -> Void)

    /// Deny authentication
    ///
    /// - Parameter completionHandler: Will return NSError in case of an error.
    @objc final public func deny(completionHandler: @escaping (NSError?) -> Void)
}

@objc public class PingOne : NSObject {

    /// Type that describes the APNS environment.
    @objc public enum APNSDeviceTokenType : NSInteger {

        /// Production environment.
        case production

        /// Sandbox environment.
        case sandbox
    }

    /// Pair device
    ///
    /// - Parameters:
    ///   - pairingKey:         The `String` value
    ///   - completionHandler:  Will return NSError in case of an error.
    @objc public static func pair(_ pairingKey: String, completionHandler: @escaping (NSError?) -> Void)

    ///  Set device remote notification token. Should be within application:didRegisterForRemoteNotificationsWithDeviceToken:
    ///
    /// - Parameters:
    ///   - deviceToken: The `Data` received within application:didRegisterForRemoteNotificationsWithDeviceToken:
    ///   - type: The `APNSDeviceTokenType` case.
    ///   - completionHandler: Will return NSError in case of an error.
    @objc public static func setDeviceToken(_ deviceToken: Data, type: PingOne.PingOne.APNSDeviceTokenType, completionHandler: @escaping (NSError?) -> Void)

    /// Get PingOne remote notification categories. Setting UNNotificationCategory more than once results in previous settings being overwritten.
    /// PingOne provides the needed categories. The developer may add categories.
    /// - Returns: The remote notification categories.
    @objc public static func getUNNotificationCategories() -> Set<UNNotificationCategory>

    /// Process the remote notification received from PingOne.
    ///
    /// - Parameters:
    ///   - userInfo: The `[AnyHashable : Any]` received in the AppDelegate application(_:didReceiveRemoteNotification:fetchCompletionHandler:) method.
    ///   - completionHandler: Will return NSError in case of an error. Will return NotificationObject in case further action is required, such as approving or denying an authentication.
    @objc public static func processRemoteNotification(_ userInfo: [AnyHashable : Any], completionHandler: @escaping (PingOne.NotificationObject?, NSError?) -> Void)

    ///  Tells PingOne to perform the custom action specified by a remote notification. Should be within userNotificationCenter(_:didReceive:withCompletionHandler:) method.
    ///
    /// - Parameters:
    ///   - identifier: The `String` is the response.actionIdentifier received within userNotificationCenter(_:didReceive:withCompletionHandler:) method.
    ///   - userInfo: The `[AnyHashable : Any]` received within userNotificationCenter(_:didReceive:withCompletionHandler:) method.
    ///   - completionHandler: Will return NSError in case of an error. NotificationObject will be returned in case an action is required.
    @objc public static func processRemoteNotificationAction(_ identifier: String, forRemoteNotification userInfo: [AnyHashable : Any], completionHandler: @escaping (PingOne.NotificationObject?, NSError?) -> Void)

    ///  **************** Warning  ****************
    /// Using this method will remove the trusted connection between the iOS SDK and the PingOne SDK
    /// server in a one sided manner, where only the iOS side will be removed.
    /// This method should not be used when logging out of your account.
    /// This method should only be used in development.
    @objc public static func removePingOneLocalData()

    /// The developer can decide if the device will stay paired after app reinstallation. This method should only be called once.
    ///
    /// - Parameter stayPaired: The `Bool` value. `true` to stay paired. Defaults to `false`.
    @objc public static func setDevicePairedAfterReinstall(_ stayPaired: Bool)
}