SAPcpmsSettingsDownloadStep
open class SAPcpmsSettingsDownloadStep : OnboardingStep
Class for SAPcpmsSettings download onboarding step handling
Customization
During the onboarding flow, if there is a splash screen which shows a text, that text can be changed/localized.
// The localized SAPcpmsSettingsDownloadStep can be created like the following code snippet
func customSettingsDownloadStep() -> OnboardingStep {
let step = SAPcpmsSettingsDownloadStep()
let sapcpmsSettingsDownloadBundle = Bundle(for: SAPcpmsSettingsDownloadStep.self)
step.infoScreenText = NSLocalizedString("SAPcpmsSettingsDownloadInfoScreenTextKey", tableName: "ExampleTableName", bundle: sapcpmsSettingsDownloadBundle, value: "Example Info Screen Text", comment: "")
return step
}
-
Transform the downloaded
SAPcpmsSettings
data to insert into theOnboardingContext
structureDeclaration
Swift
public let transformer: ConfigurationTransforming
-
The
OnboardingInfoKey
associated with an instance of downloadedSAPcpmsSettings
(PasscodePolicy and LogSettings) in theOnboardingContext
info.Declaration
Swift
public let settingsInfoKey: OnboardingInfoKey
-
Key to store the SAPcpmsSettings in CredentialStore
Declaration
Swift
public let sapcpmsSettingsStoreKey: String
-
The
OnboardingInfoKey
associated with an instance of previous context in theOnboardingContext
info.Declaration
Swift
public let previousSettingsInfoKey: OnboardingInfoKey
-
Property to set the title of info screen
Declaration
Swift
public var infoScreenText: String
-
Initializes the object
Declaration
Swift
public init(transformer: ConfigurationTransforming = ConfigurationTransformer(transformationMap: SAPcpmsSettingsTransformationMap), settingsInfoKey: OnboardingInfoKey = .sapcpmsSettingsParameters, previousSettingsInfoKey: OnboardingInfoKey = .previousSettings)
Parameters
transformer
used to transform the settings downloaded from SAPcpms to [OnboardingInfoKey: Any] where the values are typed objects, like FUIPasscodePolicy and LogSettings
settingsInfoKey
the key where the downloaded SAPcpmsSettings can be available in the info field of the OnboardingContext in case the automatic onboarding mode is used
previousSettingsInfoKey
for this key saved the step the previous
SAPcpmsSettings
-
Onboarding function with
OnboardingContext
support; Downloads the configured Settings from mobile services and updates the stored settings with them in the ‘context’.Declaration
Swift
open func onboard(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)
Parameters
context
OnboardingContext
object which contains every information for the OnboardingStepcompletionHandler
called when the process finished. Error filled on failure.
-
Restore function with
OnboardingContext
supportDeclaration
Swift
open func restore(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)
Parameters
context
OnboardingContext
object which contains every information for the OnboardingStepcompletionHandler
called when the process finished. Error filled on failure.
-
resetPasscode function with
OnboardingContext
supportDeclaration
Swift
open func resetPasscode(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)
Parameters
context
completionHandler
called when the process finished. Step OnboardingResult filled.
-
This function resets the modifications of SAPcpmsDownloadStep modifications in
OnboardingContext
Declaration
Swift
open func reset(context: OnboardingContext, completionHandler: @escaping () -> Void)
Parameters
context
OnboardingContext
object which contains every information for the OnboardingStepcompletionHandler
called when the process finished.
-
Onboarding function without context for SAPcpmsSettings download.
Declaration
Swift
open func onboard(sapURLSession: SAPURLSession, credentialStore: CodableStoring, settingsParameters: SAPcpmsSettingsParameters, presentationDelegate: FlowPresentationDelegate, completionHandler: @escaping ([OnboardingInfoKey : Any]?, Error?) -> Void)
Parameters
sapURLSession
SAPURLSession
that handle the connection to download settingscredentialStore
credentials will be saved in the given store
settingsParameters
SAPcpmsSettingsParameters
objectpresentationDelegate
FlowPresentationDelegate
object which handles the presentationcompletionHandler
called when the process finished. Error filled on failure.
-
Restore function without context for SAPcpmsSettings download. Tries to download the settings from SAPcpms server again then stores in the given store. Overwrites the previously applied settings.
- If the download fails because the Settings is turned off on the server and the received statuscode is 404, then the settings are deleted from the store.
If the download fails for some other reason, loads the previously saved settings from the given store.
Declaration
Swift
open func restore(sapURLSession: SAPURLSession, credentialStore: CodableStoring, settingsParameters: SAPcpmsSettingsParameters, presentationDelegate: FlowPresentationDelegate, completionHandler: @escaping ([OnboardingInfoKey : Any]?, Error?) -> Void)
Parameters
sapURLSession
SAPURLSession
that handle the connection to download settingscredentialStore
credentials will be saved in or loaded from the given store
settingsParameters
SAPcpmsSettingsParameters
objectpresentationDelegate
FlowPresentationDelegate
object which handles the presentationcompletionHandler
called when the process finished. Error filled on failure.
-
This function resets the modifications of the SAPcpmsDownloadStep in the SAPURLSession.
Declaration
Swift
open func reset(store: CodableStoring, completionHandler: @escaping () -> Void)
Parameters
store
CodableStoring
storage which stores the SAPcpmsSettingscompletionHandler
called when the process finished.
-
Loads the persisted settings from the given credentialStore
Throws
throws an error in cases of failure of parsing JSONDeclaration
Swift
public func loadPersistedSettingsData(from credentialStore: CodableStoring) throws -> [OnboardingInfoKey : Any]
Parameters
credentialStore
the store that contains the settings
Return Value
dictionary with the settings