UsageUserConsentStep

open class UsageUserConsentStep : OnboardingStep, FUIUserConsentViewControllerDelegate

Class that provides localized Usage Data Collection UsageUserConsentStep, Opt-in, and Opt-out alerts.

Manages the Usage User Consent Handling. The version for each user consent form will be stored in the credentialStore of the OnboardingContext which is used to decide if a newer version of the form should be presented in the next run. If a new version for the form is present, the form will be displayed in the next run to request user confirmation.

Usage

Simplest model - default single page form.
let usageUserConsentStep = UsageUserConsentStep()
Creates a localized title and body that will collect user preference for usage data collection.

Customization model - allow customized single page form.
let title = "Custom UsageUserConsent Title"
let body = "Custom UsageUserConsent Body"
let usageUserConsentStep = UsageUserConsentStep(title: title, body: body)

Customization model with additional page - allow customized multi page form.
var spDpPage = UserConsentPageContent()
spDpPage.title = "Data Privacy Details"
spDpPage.body = "Your customized data privacy text"
var spSecPage = UserConsentPageContent()
spSecPage.title = "Security Details"
spSecPage.body = "Your customized security text"
let usageUserConsentStep = UsageUserConsentStep(title: title, body: body, additionalUserPageContent: [spDpPage, spSecPage])

User selection will be enacted, and will be published in context.
Response can be accessed as follows in AppDelegate onboarded delegate method using default key:
if let consent = onboardingContext.info[.usageUserConsentResponseInfoKey] {
or an alternate key if it was set on the step as:
onboardingContext.info[yourUsageStep.usageConsentResponseInfoKey]

Class also contains both localized and custom opt-in and opt-out alerts that may be used to prompt user as needed.

Default opt-in default model called from your app:
UsageUserConsentStep.UsageUserConsentOptIn(viewController: self) { response in
                                          if response {
                                              Usage.shared.consentForUser(userUUID, given: response)
                                          }
                                      }
Customized opt-in model called from your app:
UsageUserConsentStep.UsageUserConsentOptIn(viewController: self, title: "Custom Opt-in Title", message: "Custom Opt-in Message")
...

Default opt-out default model called from your app:
UsageUserConsentStep.UsageUserConsentOptOut(viewController: self) { response in
                                          if response {
                                              Usage.shared.consentForUser(userUUID, given: !response)
                                          }
                                      }
Customized opt-out model called from your app:
UsageUserConsentStep.UsageUserConsentOptOut(viewController: self, title: "Custom Opt-out Title", message: "Custom Opt-out Message")
...
  • Read-only access to UsageUserConsentStep version set through initialization.

    Declaration

    Swift

    private(set) public var version: String
  • Read-only access to UsageUserConsentStep title set through initialization.

    Declaration

    Swift

    private(set) public var title: String
  • Read-only access to UsageUserConsentStep body set through initialization.

    Declaration

    Swift

    private(set) public var body: String
  • The current usage user consent info version for the form is stored under this key if the user accepts it. It is used in the restore flow to decide if a new version of the form should be presented.

    Declaration

    Swift

    public var usageUserConsentVersionStoreKey: String
  • Custom property of usageUserConsentResponseInfoKey

    Declaration

    Swift

    open var usageUserConsentResponseInfoKey: OnboardingInfoKey
  • Initializer used to construct UserConsentStep.

    Declaration

    Swift

    public init(version: String = "1.0", title: String? = nil, body: String? = nil, additionalUserPageContent: [UserConsentPageContent]? = nil)

    Parameters

    version

    used for UserConsentStep construction.

    title

    used for UserConsentStep construction.

    body

    used for UserConsentStep construction.

    additionalUserPageContent

    if multi-page content is desired, optionally submit them here.

  • Onboard function for Usage User Consent handling. The version of the Usage User Consent for each form will be persisted under the usageUserConsentVersionStoreKey key. This is used in the restore flow to decide if the content of the user consent has changed or not.

    Declaration

    Swift

    open func onboard(userConsentFormsContent: [UserConsentFormContent], presentationDelegate: FlowPresentationDelegate, credentialStore: CodableStoring, completionHandler: @escaping (Bool, Error?) -> Void)

    Parameters

    userConsentFormsContent

    the user consent forms content to be presented.

    presentationDelegate

    the presentation delegate which is used to put up the user consent screens.

    credentialStore

    the credential store which contains the current user consent forms content version.

    completionHandler

    return usage user consent response, otherwise provide an error.

  • Restore function for usage user consent forms handling. Reads the usageUserConsentVersionStoreKey value from the store. For every form, checks if the stored version of the form differs from the current version, then presents those forms for confirmation.

    Declaration

    Swift

    open func restore(userConsentFormsContent: [UserConsentFormContent], presentationDelegate: FlowPresentationDelegate, credentialStore: CodableStoring, completionHandler: @escaping (Bool, Error?) -> Void)

    Parameters

    userConsentFormsContent

    the UserConsentFormsContent to be presented.

    presentationDelegate

    the presentation delegate which is used to display the user consent screens.

    credentialStore

    the credential store which contains the current user consent formscontent version.

    completionHandler

    return usage user consent response, otherwise provide an error.

  • Reset function for usge user consent form handling. Clears the usageUserConsentVersionStoreKey value from the store.

    Declaration

    Swift

    open func reset(credentialStore: CodableStoring, completionHandler: @escaping () -> Void)

    Parameters

    credentialStore

    the credential store which contains the current usage user consent content.

    completionHandler

    the completion handler that gets called at the end of the process.

  • Localized Opt-in Alert for Usage Data Collection.

    Declaration

    Swift

    public static func UsageUserConsentOptIn(viewController: UIViewController, title: String? = nil, message: String? = nil,
                                             completionHandler: @escaping (Bool) -> Void)

    Parameters

    viewController

    required for UI presentation.

    title

    optional input.

    message

    optional input.

    completionHandler

    user response.

  • Localized Opt-out Alert for Usage Data Collection.

    Declaration

    Swift

    public static func UsageUserConsentOptOut(viewController: UIViewController, title: String? = nil, message: String? = nil,
                                              completionHandler: @escaping (Bool) -> Void)

    Parameters

    viewController

    required for UI presentation.

    title

    optional input.

    message

    optional input.

    completionHandler

    user response.