Skip to content

You can check the current consent status by calling:

let result = spConsentEngine.getConsentStatus(applicationId: "YOUR_APPLICATION_ID")
let status = result.data
switch status {
case .pending:
// Show consent banner
case .collected:
// Proceed normally
case .recollectionRequired:
// Trigger re-consent flow
}

When the SDK determines that consent needs to be recollected (for example, a consent update/re-consent flow), you can fetch the reason by calling:

let result = spConsentEngine.getConsentRecollectionReason(applicationId: "YOUR_APPLICATION_ID")
let reason: SPConsentRecollectionReason? = result.data
if let reason {
switch reason {
case .expired:
// Handle expired
case .structureChanged:
// Handle structure change
}
}

If no recollection reason is available, reason will be nil.

CaseRaw valueMeaning
expiredexpiredConsent has expired and needs to be re-collected.
structureChangedstructure_changedPackages and services hash mismatch.

SDK enums are the authoritative representation for consent status and recollection reasons. The SDK guarantees the enum contract, but does not guarantee that raw string values remain stable.

Prefer enums in your app logic:

  • Use switch on enums
  • Avoid branching on raw string values
  • Map to your own keys if needed
let myReasonKey: String? = {
guard let reason else { return nil }
switch reason {
case .expired: return "MY_EXPIRED"
case .structureChanged: return "MY_STRUCTURE_CHANGED"
}
}()

The SDK supports three consent states:

  • Collected: Consent has already been obtained.
  • Pending: Consent needs to be collected.
  • RecollectionRequired: Consent needs to be re-collected.
let result = spConsentEngine.getPackage(
applicationId: "YOUR_APPLICATION_ID",
packageId: "Package-Id-To-Find"
)
if let spPackage = result.data {
if spPackage.enabled() {
// Enable features
}
}

This returns an SPDataMessage containing an optional SPPackageConsent. Check enabled() to determine user consent.

do {
let result = try spConsentEngine.showConsentBannerFor(
applicationId: "YOUR_APPLICATION_ID",
vc: vc
)
if result.code != 200 {
print("Error: \(result.msg)", result.error ?? "")
}
} catch {
print("Error: \(error)")
}

This banner informs users about data collection and provides options to accept, deny, or customize consent.

Users can customize their preferences via the Preference Center:

do {
let result = try spConsentEngine.showPreferenceCenter(
applicationId: "YOUR_APPLICATION_ID",
in: vc
)
if result.code != 200 {
print("Error: \(result.msg)", result.error ?? "")
}
} catch {
print("Error: \(error)")
}

You can mark certain services as essential. These cannot be disabled by users.

The Preferences screen includes a tab showcasing content related to the app’s privacy policy.

Users can submit data requests via the Request Data section.