DataCollectionConsentStep

open class DataCollectionConsentStep : OnboardingStep, FUIUserConsentViewControllerDelegate

Class that provides localized User Data Collection with Opt-in, and Opt-out alerts available for Usage Data Collection.

Manages the User Data Collection 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.

Note: Crash report collection consent and related properties/keys are excluded from visionOS.

Usage

Simplest model - default single page forms.
let dataCollectionConsentStep = DataCollectionConsentStep()
Creates a localized title and body that will collect user preference for both usage and crash data collection.

Customization model - allow customized single page form.
let title = "Custom UsageCollectionConsent Title"
let body = "Custom UsageCollectionConsent Body"
let dataCollectionConsentStep = DataCollectionConsentStep(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 dataCollectionConsentStep = DataCollectionConsentStep(title: title, body: body, additionalUserPageContent: [spDpPage, spSecPage])

Customization model with additional page(allow customized multi page form) and customized crash report collection consent object.
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 crashReportCollectionConsent = CrashReportCollectionConsent(version: <optionally give the version as String>, userConsentPagesContent: [<optionally give array of objects of type UserConsentPageContent>])
let dataCollectionConsentStep = DataCollectionConsentStep(title: title, body: body, additionalUserPageContent: [spDpPage, spSecPage], crashReportCollectionConsent: crashReportCollectionConsent)

Customization model with customized usage collection consent object and customized crash report collection consent object.
let usageCollectionConsent = UsageCollectionConsent(version: <optionally give the version as String>, userConsentPagesContent: [<optionally give array of objects of type UserConsentPageContent>])
let crashReportCollectionConsent = CrashReportCollectionConsent(version: <optionally give the version as String>, userConsentPagesContent: [<optionally give array of objects of type UserConsentPageContent>])
let dataCollectionConsentStep = DataCollectionConsentStep(usageCollectionConsent: usageCollectionConsent, crashReportCollectionConsent: crashReportCollectionConsent)

User selection will be enacted, and will be published in context.
Responses can be accessed as follows in AppDelegate onboarded delegate method using default key:
if let consentForUsage = onboardingContext.info[.usageCollectionConsentResponseInfoKey] {
or an alternate key if it was set on the step as:
onboardingContext.info[yourDataCollectionConsentStep.usageConsentResponseInfoKey]
if let consentForCrash = onboardingContext.info[.crashCollectionConsentResponseInfoKey] {
or an alternate key if it was set on the step as:
onboardingContext.info[yourDataCollectionConsentStep.crashConsentResponseInfoKey]

Class also contains both localized and custom usage 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:
DataCollectionConsentStep.UsageCollectionConsentOptOut(viewController:
or opt-in:
DataCollectionConsentStep.UsageCollectionConsentOptIn(viewController:

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

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    private(set) public var body: String { get }
  • 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 usageCollectionConsentVersionStoreKey: String
  • Custom property of usageCollectionConsentResponseInfoKey

    Declaration

    Swift

    open var usageCollectionConsentResponseInfoKey: OnboardingInfoKey
  • The current crash 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 crashCollectionConsentVersionStoreKey: String
  • Custom property of crashCollectionConsentResponseInfoKey

    Declaration

    Swift

    open var crashCollectionConsentResponseInfoKey: OnboardingInfoKey