UsageCollectionConsentStep

open class UsageCollectionConsentStep : OnboardingStep, FUIUserConsentViewControllerDelegate

Class that provides localized Usage Data Collection UsageCollectionConsentStep, 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 UsageCollectionConsentStep = UsageCollectionConsentStep()
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 UsageCollectionConsent Title"
let body = "Custom UsageCollectionConsent Body"
let UsageCollectionConsentStep = UsageCollectionConsentStep(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 UsageCollectionConsentStep = UsageCollectionConsentStep(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[.usageCollectionConsentResponseInfoKey] {
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.
Intended use for these helper methods:

Obtain current user state: if(Usage.shared.hasConsentForUser(userUUID))

Then call whatever is appropriate for your situation.
- either opt-out:
UsageCollectionConsentStep.UsageCollectionConsentOptOut(viewController:
or opt-in:
UsageCollectionConsentStep.UsageCollectionConsentOptIn(viewController:

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

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

    Declaration

    Swift

    private(set) public var version: String {
      get
      }
  • Read-only access to UsageCollectionConsentStep title set through initialization.

    Declaration

    Swift

    private(set) public var title: String {
      get
      }
  • Read-only access to UsageCollectionConsentStep body set through initialization.

    Declaration

    Swift

    private(set) public var body: String {
      get
      }
  • Undocumented

    Declaration

    Swift

    public var usageCollectionConsentVersionStoreKey: String
  • Undocumented

    Declaration

    Swift

    open var usageCollectionConsentResponseInfoKey: 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 usageCollectionConsentVersionStoreKey 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 usageCollectionConsentVersionStoreKey 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 usageCollectionConsentVersionStoreKey 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.