Data Collection Consent
Control when the Pulse iOS SDK collects and exports telemetry, in compliance with GDPR and App Store privacy requirements.
Consent States
| State | Behavior |
|---|---|
.allowed | SDK fully active — telemetry collected and exported |
.pending | SDK initialized but paused — telemetry buffered, nothing exported |
.denied | Terminal — buffer cleared, SDK shuts down. Cannot be undone in the same process. |
Setting the Initial State
Pass dataCollectionState to initialize(). Default is .allowed.
Pulse.shared.initialize(
endpointBaseUrl: "https://your-backend.com",
apiKey: "your-api-key",
dataCollectionState: .pending // wait for user consent
)
Updating State at Runtime
Use setDataCollectionState(_:) to transition state after initialization:
// User granted consent — flushes any buffered signals and starts exporting
Pulse.shared.setDataCollectionState(.allowed)
// User denied consent — clears buffer and shuts down the SDK
Pulse.shared.setDataCollectionState(.denied)
Valid Transitions
| From | To .allowed | To .denied |
|---|---|---|
.pending | ✅ Flushes buffer, starts exporting | ✅ Clears buffer, shuts down |
.allowed | — (no-op) | ✅ Clears buffer, shuts down |
.denied | ❌ Terminal — no transitions possible | — |
warning
.denied is a terminal state. Once set, the SDK is shut down for the lifetime of the process. Restart the app to re-initialize.
Typical Flow: Consent Gate
Initialize with .pending at app start, then update state based on the user's choice:
@main
struct MyApp: App {
init() {
Pulse.shared.initialize(
endpointBaseUrl: "https://your-backend.com",
apiKey: "your-api-key",
dataCollectionState: .pending
)
// If consent was already granted in a previous session, apply it now
if UserDefaults.standard.bool(forKey: "pulse.consent.allowed") {
Pulse.shared.setDataCollectionState(.allowed)
}
}
}
// Called when user interacts with your consent UI
func onConsentGranted() {
UserDefaults.standard.set(true, forKey: "pulse.consent.allowed")
Pulse.shared.setDataCollectionState(.allowed)
}
func onConsentDenied() {
UserDefaults.standard.set(false, forKey: "pulse.consent.allowed")
Pulse.shared.setDataCollectionState(.denied)
}
Next Steps
- Upload symbol — Upload symbol files
- API Reference — Browse all public methods