OnboardingSession

open class OnboardingSession

Stores information about an onboarding session Application developer can subclass OnboardingSession to add other app related meaningful properties or to set properties properly. For example when the SAPcpmsSettingsParameters is not stored using the default key in OnboardingContext then subclasses have to implement the code to provide the SAPcpmsSettingsParameters based on the used key

open class YourSession: OnboardingSession {
    var appURL: URL!
    var otherIntProperty: Int = 0
    var appDict = [String: Any]()

    required public init(flow: OnboardingFlow) {
       super.init(flow: flow)

        // When SAPcpmsSettingsParameters is under another key
        self.settingsParameters = flow.context.info[.yourSettingsParameters] as? SAPcpmsSettingsParameters

        self.appURL = URL(string:"")
        self.otherIntProperty = 12
        self.appDict = ["a":"b"]
    }
}
  • Onboarding ID

    Declaration

    Swift

    public let onboardingID: UUID
  • Authentication URL

    Declaration

    Swift

    public let authenticationURL: URL?
  • Credentials Store

    Declaration

    Swift

    public let credentialStore: CompositeCodableStoring
  • SAPURLSession

    Declaration

    Swift

    public let sapURLSession: SAPURLSession
  • SettingsParameters

    Declaration

    Swift

    public let settingsParameters: SAPcpmsSettingsParameters?
  • Type of flow

    Declaration

    Swift

    public let flowType: OnboardingFlow.FlowType
  • Presentation Delegate

    Declaration

    Swift

    public let presentationDelegate: FlowPresentationDelegate
  • Initializer If customs OnboardingInfoKeys are being used, then the init must be overriden.

    Declaration

    Swift

    public required init(flow: OnboardingFlow)

    Parameters

    flow

    OnboardingFlow that contains the necessary fields (by default)

  • Returns with a new OnboardingContext filled with the values from this session

    Declaration

    Swift

    open func onboardingContext() -> OnboardingContext
  • Invalidates the OnboardingSession. After this method has been called, the SAPURLSession, the CredentialStore and other fields cannot be used - behavior is undefined if used

    Declaration

    Swift

    open func invalidate()
  • Creates a new instance of a properly configured store manager which can be used to perform ‘unlock’ functionality by calling openStore or performing change passcode scenarios see: StoreManager documentation and availablePasscodeActions and performPasscodeAction methods The default implementation uses the default values of the StoreManager and the SAPcpmsSettingsDownloadStep to load the FUIPAsscodePolicy. This method must be overriden * If the StoreManager’s defaultPasscodePolicy was changed * the policy was downloaded on other ways * the policy is stored under custom key (for example a custom ConfigurationTransformer was used)

    Declaration

    Swift

    open func storeManager() throws -> StoreManager

    Return Value

    Configured StoreManager instance swift // using store manager and setting the default passcode policy to nil open override func storeManager() throws -> StoreManager { let storeManager = try super.storeManager() storeManager.defaultPasscodePolicy = nil return storeManager }

  • Upload Logs

    Declaration

    Swift

    public func uploadLogs(completionHandler: @escaping (Error?) -> Void = SAPcpmsLogUploader.defaultCompletionHandler)

    Parameters

    completionHandler

    closure called upon completion

  • Upload the device token to the server

    Declaration

    Swift

    public func registerDeviceToken(deviceToken: Data, withParameters parameters: SAPcpmsRemoteNotificationParameters?, completionHandler: @escaping (Error?) -> Void)

    Parameters

    deviceToken

    the device token from application:didRegisterForRemoteNotificationsWithDeviceToken delegate

    completionHandler

    called after the request completes; The parameter is an Error that could be nil.

  • Unregister the existing device token from the server

    Declaration

    Swift

    public func unregisterDeviceToken(completionHandler: @escaping (Error?) -> Void)

    Parameters

    completionHandler

    called after the request completes; The parameter is an Error that could be nil.

  • Provide information about the notification status. This adjusts the notification status to ‘consumed’ on SAP Cloud Platform Mobile Services cockpit Reporting menu.

    Declaration

    Swift

    public func updateNotificationStatus(userInfo: [AnyHashable: Any], completionHandler: @escaping (Error?) -> Void)

    Parameters

    userInfo

    userInfo parameter from the ‘didReceiveRemoteNotification’ application delegate

    completionHandler

    called after the request completes; The parameter is an Error that could be nil.

  • Collects the usage records for the given target identifier, and uploads them in the SAPcpms format to the given endpoint. After the upload a new session should be started.

    Declaration

    Swift

    public func uploadUsageData(completionHandler: @escaping (Error?) -> Void = SAPcpmsUsageUploader.defaultCompletionHandler)

    Parameters

    completionHandler

    closure called upon completion

  • Queries user roles from the server

    Declaration

    Swift

    public func userRoles(completionHandler: @escaping (SAPcpmsUserRoles.SAPcpmsUserInfo?, Error?) -> Void)

    Parameters

    completionHandler

    closure called upon completion

  • Logout error enum

    • noResponseData: no response data received
    • invalidResponse: invalid response with given status code
    See more

    Declaration

    Swift

    public enum LogoutError : Error
  • Logs out the user on the server (invalidating the authentication tokens) Does not invalidate the OnboardingSession! The next requst should trigger an authentication automatically

    Declaration

    Swift

    public func logout(completionHandler: @escaping (Error?) -> Void)

    Parameters

    completionHandler

    closure called on completion