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.
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 }
-
Undocumented
Declaration
Swift
public var usageCollectionConsentVersionStoreKey: String
-
Undocumented
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
-
Initializer used to construct DataCollectionConsentStep with some optional customization
Declaration
Swift
public init(version: String = "1.0", title: String? = nil, body: String? = nil, additionalUserPageContent: [UserConsentPageContent]? = nil, crashReportCollectionConsent: CrashReportCollectionConsent = CrashReportCollectionConsent())
Parameters
version
used for UsageCollectionConsent construction.
title
used for UsageCollectionConsent construction.
body
used for UsageCollectionConsent construction.
additionalUserPageContent
if multi-page content for Usage Consent is desired, optionally submit them here.
crashReportCollectionConsent
If customized Crash Report Collection Consent Page is required optionally submit the object of type CrashReportCollectionConsent here.
-
Initializer used to construct DataCollectionConsentStep with UsageCollectionConsent and CrashReportCollectionConsent object.
Declaration
Swift
public init(usageCollectionConsent: UsageCollectionConsent = UsageCollectionConsent(), crashReportCollectionConsent: CrashReportCollectionConsent = CrashReportCollectionConsent())
Parameters
usageCollectionConsent
If customized Usage Collection Consent Page is required optionally submit the object of type UsageCollectionConsent here.
crashReportCollectionConsent
If customized Crash Report Collection Consent Page is required optionally submit the object of type CrashReportCollectionConsent here.
-
Onboard function for User Data Collection Consent handling. The version of the Usage Data Collection Consent and Crash Data Collection Consent form will be persisted under the
usageCollectionConsentVersionStoreKey
andcrashCollectionConsentVersionStoreKey
key respectively. 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 user consent responses, otherwise provide an error.
-
Restore function for user data collection consent forms handling. Reads the
usageCollectionConsentVersionStoreKey
andcrashCollectionConsentVersionStoreKey
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 user consent responses, otherwise provide an error.
-
Reset function for user consent forms handling. Clears the
usageCollectionConsentVersionStoreKey
andcrashCollectionConsentVersionStoreKey
value from the store.Declaration
Swift
open func reset(credentialStore: CodableStoring, completionHandler: @escaping () -> Void)
Parameters
credentialStore
the credential store which contains the current user consent content.
completionHandler
the completion handler that gets called at the end of the process.
-
Onboard function for user data collection consent handling. The versions of the forms will be persisted under the
usageCollectionConsentVersionStoreKey
andcrashCollectionConsentVersionStoreKey
key. This is used in the restore flow to decide if the content of the usage user consent forms content has changed or not.Declaration
Swift
open func onboard(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)
Parameters
context
completionHandler
called when the process finished. Error filled on failure.
-
Restore function for user data collection consent forms handling. Reads the
usageCollectionConsentVersionStoreKey
andcrashCollectionConsentVersionStoreKey
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(context: OnboardingContext, completionHandler: @escaping (OnboardingResult) -> Void)
Parameters
context
completionHandler
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.
-
Reset function for user data collection consent forms handling. Clears the
usageCollectionConsentVersionStoreKey
andcrashCollectionConsentVersionStoreKey
value from the store.Declaration
Swift
open func reset(context: OnboardingContext, completionHandler: @escaping () -> Void)
Parameters
context
completionHandler
called when the process finished. Error filled on failure.
-
Gets called after the user input is completed for all the forms displayed.
Declaration
Swift
public func userConsentViewController(viewController: FUIUserConsentViewController, didReceiveResponseToConsentForms forms: [FUIUserConsentForm])
-
Gets called when the user cancels any form
Declaration
Swift
public func userConsentViewController(viewController: FUIUserConsentViewController, didCancelConsentForms forms: [FUIUserConsentForm])
-
Undocumented
Declaration
Swift
public static func UsageCollectionConsentOptIn(viewController: UIViewController, title: String? = nil, message: String? = nil, completionHandler: @escaping (Bool) -> Void)
-
Undocumented
Declaration
Swift
public static func UsageCollectionConsentOptOut(viewController: UIViewController, title: String? = nil, message: String? = nil, completionHandler: @escaping (Bool) -> Void)