Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ choice. Apps that persist a user's own decision leave `StorageDefaults.consent`
`client.consent(false)` after they reject.
3. Use the split form when events are allowed but durable profile continuity must stay session-only.
4. Read `client.state.consent` and `client.state.persistenceConsent` when consent UI must reflect SDK
state.
state. `client.state.consent` is tri-state — `true`, `false`, or `nil` when the visitor has not
decided yet — so gate the banner on `client.state.consent == nil` to show it only until a choice is
made.

**Adapt this to your use case:**

Expand All @@ -319,6 +321,20 @@ struct ConsentBanner: View {
}
}
}

struct ConsentGate<Content: View>: View {
@EnvironmentObject private var client: OptimizationClient
@ViewBuilder var content: () -> Content

var body: some View {
// consent is nil until the visitor decides; show the banner only while undecided.
if client.state.consent == nil {
ConsentBanner()
} else {
content()
}
}
}
```

**Copy this:**
Expand Down Expand Up @@ -369,6 +385,10 @@ events use. Keep them aligned when rendered content and Experience responses mus
4. When the app locale changes, call `client.setLocale(...)`, refetch entries with the new locale, and
re-render. `setLocale(...)` updates only the SDK Experience/event locale; it does not refetch
Contentful or refresh profile state, and it throws before initialization or on an invalid locale.
5. After the locale change, emit a fresh Experience event — the `screen`, `identify`, or `page` call
your app already owns for the current state — when rendered output depends on SDK-derived profile
data, selected optimizations, flags, or MergeTags that must reflect the new locale. Without a new
event, those stay on the previous locale's response.

**Adapt this to your use case:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,12 @@ final class OptimizedEntryView: UIView {
}
```

`ViewTrackingController` is the recommended path because it applies the SDK's visibility timing for
you. If your app already computes its own visibility and duration — or needs a single one-off view
event — call `client.trackView(TrackViewPayload(...))` directly instead of using the controller; it
is the lower-level `async throws` primitive the controller wraps, and you then own the timing the
controller would otherwise apply.

To opt an entry out of view or tap tracking, do not install its controller or gesture recognizer.
For shared tracking mechanics, see
[iOS SDK runtime and interaction mechanics](../concepts/ios-sdk-runtime-and-interaction-mechanics.md#tracking-mechanics).
Expand Down