Skip to main content
TriggerProvider enables reactive updates when users enter or exit cohorts, allowing your app to respond to segment changes in real-time.

Cohort Triggers

Query Triggers

User ID

Overview

TriggerProvider provides:
  • Real-time cohort change notifications
  • Immediate callback when users enter/exit cohorts
  • Query-based triggers for complex conditions
  • User identity change monitoring
Use TriggerProvider instead of polling cohorts or activations for reactive behavior.

Accessing TriggerProvider

Cohort Membership Triggers

Watch for changes in cohort membership:

Watching Multiple Cohorts

Query Triggers

For more complex data, use query triggers that return dictionaries or integers:

Dictionary Queries

Integer Queries

User ID Triggers

Monitor changes to the user identity:

TriggerAction Lifecycle

You must maintain a strong reference to TriggerAction objects. Releasing the reference stops the trigger.

Keeping Triggers Active

UIViewController Integration

SwiftUI Integration

tvOS Considerations

tvOS Note: TriggerProvider works identically on tvOS. Use it to update UI elements based on cohort membership in your focus-based navigation.

Best Practices

  • Store TriggerAction references as instance properties
  • Use [weak self] in closures to avoid retain cycles
  • Dispatch UI updates to main thread
  • Release triggers when no longer needed
  • Group related cohorts in a single trigger

Troubleshooting

Problem: No callbacks when cohort membership changes.Solutions:
  • Verify you’re storing a strong reference to TriggerAction
  • Check that cohort IDs match your dashboard
  • Enable debug logging to see cohort updates
  • Ensure SDK is initialized before creating triggers
Problem: Trigger worked initially but stopped.Cause: TriggerAction reference was released.Solution: Store TriggerAction as an instance property, not a local variable.
Problem: Callback fires but UI doesn’t change.Solution: Dispatch UI updates to main thread:

Cohorts & Activations

Understanding user segments

Identity Management

User identity tracking

Page Tracking

Trigger cohort qualification

Issues

Common problems and solutions