New in CUX: Mobile Analytics. Analyze real user behavior inside your app. Learn More

Control iOS collection and mask content

Control iOS collection and mask content

Browse topics

On this page

Control when your iOS app collects analytics and hide sensitive content before capture. Screenshot controls are separate from collection controls.

Version covered: 1.1.11. Requires iOS 15 or later.

Initialize in a waiting state

Set needConfirmToStart: true in your single SDK initialization if collection must wait for consent. Do not call setup() again when consent changes.

Control data collection

If you initialized with needConfirmToStart: true, start collection after your app obtains consent:

CuxAnalytics.shared.resumeCollectingData()

Stop it when consent is withdrawn:

CuxAnalytics.shared.stopCollectingData()

isCollectingData() reports collection state. Set the initialization option to false only when collection should start immediately. Keep your consent choice consistent across app launches.

Hide sensitive content

For an existing UIKit View:

CuxAnalytics.shared.maskUIView(view: accountBalanceView)

When you deliberately want that View to become visible in later screenshots, use unmaskUIView(view:). Register a mask before sensitive content can be captured.

For SwiftUI:

Text(accountBalance)
    .maskElement()

accountBalanceView and accountBalance refer to your app's own View/value. Check custom inputs, labels, images, overlays and reused cells. Do not rely on input-type handling alone to protect every screen.

You can pause screenshots while keeping other collection active:

CuxAnalytics.shared.pauseScreenshots()
// Resume after leaving the sensitive screen.
CuxAnalytics.shared.resumeScreenshots()

Wire these calls to separate entry/exit points in your app, rather than executing them consecutively. areScreenshotsPaused() reports screenshot-pause state. Screenshot pause and masks do not filter user properties or event values.

Verify collection and masking

Use synthetic data. Check behavior before consent, after consent, after withdrawal and across app launches. Inspect available screenshots after navigation, scrolling, rotation and loading content. Include custom views, overlays and reused list cells.

Review screen names, identifiers and event parameters separately. A visual mask does not remove those values. See Mobile masking and privacy for the shared checklist.

If sensitive content appears, stop collection for the affected test, correct the configuration and repeat the journey. Follow iOS troubleshooting if it still appears.