UserConsentStep

open class UserConsentStep : OnboardingStep, FUIUserConsentViewControllerDelegate

Manages the 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

// Content for the single page form
let spTitle = "Data Privacy"
let spText = "Detailed text about how data privacy pertains to this app and why it is important for the user to enable this functionality"
let spActionTitle = "Learn more about Data Privacy"

var spPageContent = UserConsentPageContent()
spPageContent.title = spTitle
spPageContent.body = spText
spPageContent.actionTitle = spActionTitle
spPageContent.actionUrl = "http://www.sap.com"
let spFormContent = UserConsentFormContent( version: "one",isRequired: true,pages: [spPageContent])

//Content for the multi Page form
let mpTitle1 = "Data Privacy"
let mpText1 = "Detailed text about how data privacy pertains to this app and why it is important for the user to enable this functionality"
let mpActionTitle1 = "Learn more about Data Privacy"
var mpPageContent1 = UserConsentPageContent()
mpPageContent1.title = mpTitle1
mpPageContent1.body = mpText1
mpPageContent1.actionTitle =  mpActionTitle1
mpPageContent1.actionHandler = { controller in
   let alert = UIAlertController(title: "Data Privacy", message: "Alert for Data Privacy Page", preferredStyle: UIAlertControllerStyle.alert)
   alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
   controller.present(alert, animated: true, completion: nil)
}

let mpTitle2 = "Security"
let mpText2 = "Detailed text about how data privacy pertains to this app and why it is important for the user to enable this functionality"
let mpActionTitle2 = "Learn more about Data Privacy"
var mpPageContent2 = UserConsentPageContent()
mpPageContent2.title = mpTitle2
mpPageContent2.body = mpText2
mpPageContent2.actionTitle =  mpActionTitle2
// When both url and action handler are set, the action handler takes precedence.
mpPageContent2.actionUrl = "http://www.sap.com"
mpPageContent2.actionHandler = { controller in
   let alert = UIAlertController(title: "Data Privacy", message: "Alert for Data Privacy Page", preferredStyle: UIAlertControllerStyle.alert)
  alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
  controller.present(alert, animated: true, completion: nil)
}

let mpTitle3 = "Consent"
let mpText3 = "Detailed text about how data privacy pertains to this app and why it is important for the user to enable this functionality"

let mpActionTitle3 = "Learn more about Data Privacy"
var mpPageContent3 = UserConsentPageContent()
mpPageContent3.title = mpTitle3

// It is possible to provide attributed text to enable adding developer defined attributes to the text other than the default.
// Eg. change the font type to "Georgia" and size to "17.0" for the body. This can be done for the title and actionTitle as well , using the
// titleAttributedText and actionTitleAttributedText respectively. When both body and bodyAttributedText are provided , the
// attributedtext version takes precedence.
//        let mpAttributes3 = [NSAttributedStringKey.font: UIFont(name: "Georgia", size: 17.0)!]
//        let mpBody3 = NSAttributedString(string: mpText3, attributes: mpAttributes3)
//        mpPageContent3.bodyAttributedText = mpBody3

mpPageContent3.body = mpText3
mpPageContent3.actionTitle =  mpActionTitle3

let mpFormContent = UserConsentFormContent( version: "one",isRequired: true,pages: [mpPageContent1, mpPageContent2, mpPageContent3])
let userConsentStep  =  UserConsentStep(userConsentFormsContent:[spFormContent, mpFormContent])
  • The current user consent info version for all the forms 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 userConsentVersionStoreKey: String
  • Instantiates the UserConsentStep. Use this step to show the user consent forms, which can be accepted or rejected.If the provided user consent version has already been accepted then this step does nothing.

    Declaration

    Swift

    public init(userConsentFormsContent: [UserConsentFormContent])

    Parameters

    userConsentFormsContent

    The content of the forms to be presented.

  • Instantiates the UserConsentStep. Use this step to display the user consent forms, which can be accepted or rejected. Use this initialization method if you want to provide the user consent content dynamically through the OnboardingContext.

    Declaration

    Swift

    public init(userConsentContentInfoKey: OnboardingInfoKey = .userConsentContentInfoKey)

    Parameters

    userConsentContentInfoKey

    the info key containing the UserConsent content in the OnboardingContext.

  • Onboard function for User Consent handling. The version of the User Consent for each form will be persisted under the userConsentVersionStoreKey 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 (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

    call this completion handler with nil if the user accepted the user consent form that is mandatory, provide an error otherwise.

  • Restore function for user consent forms handling. Reads the userConsentVersionStoreKey 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 (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

    call this completion handler with nil if the user accepted the user consent form which is mandatory, provide an error otherwise.

  • Reset function for user consent form handling. Clears the userConsentVersionStoreKey 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.