Managing Live Activities locally
Live Activities are dynamic interfaces that display real-time information on iOS devices. Voltra provides a comprehensive set of APIs for managing the complete lifecycle of Live Activities directly from your React Native app, without requiring server-side infrastructure.
Overview
Managing Live Activities locally involves four main phases:
- Starting a Live Activity with initial content and configuration
- Updating the content and configuration as data changes
- Monitoring state changes and user interactions
- Stopping the Live Activity when it's no longer needed
Voltra offers both imperative APIs for direct control and React hooks for seamless integration with your components.
Imperative APIs
The imperative APIs provide direct, programmatic control over Live Activities. These are the core functions you'll use to manage Live Activity lifecycles.
Starting Live Activities
Use startLiveActivity() to create and display a new Live Activity.
Parameters:
variants: ALiveActivityVariantsobject defining the UI for different display contextsoptions: Configuration options (see Configuration Options section below)
Returns: A promise that resolves to the Live Activity ID (string)
Updating Live Activities
Use updateLiveActivity() to modify the content and configuration of an active Live Activity.
Parameters:
activityId: The ID returned fromstartLiveActivity()variants: Updated UI variantsoptions: Updated configuration options
Stopping Live Activities
Use stopLiveActivity() to end a Live Activity.
Parameters:
activityId: The ID of the Live Activity to stopoptions: Final configuration options
Checking Live Activity status
Use isLiveActivityActive() to check if a specific Live Activity is currently active.
Parameters:
activityName: The name of the Live Activity to check (same asactivityNameused when starting the activity)
Returns: Boolean indicating whether the Live Activity is currently active
Utility functions
Platform detection
Ending all Live Activities
Use endAllLiveActivities() to immediately end all active Live Activities in your app.
Note: This function ends all Live Activities immediately without applying any dismissal policies. Use this for bulk cleanup scenarios rather than individual activity management.
Development tools
For development-friendly APIs that provide automatic updates and easier testing, see the Development documentation.
Event handling
Live Activities emit events that you can listen to for state changes and user interactions. See the Events API documentation for detailed information on subscribing to and handling Live Activity events.
Configuration options
Voltra provides several configuration options to control Live Activity behavior, lifecycle, and appearance. These options can be used with startLiveActivity(), updateLiveActivity(), and stopLiveActivity().
Dismissal policy
Controls how Live Activities behave after they end.
Options:
'immediate'(default): Live Activity is dismissed immediately when it ends{ after: number }: Live Activity remains visible for the specified number of seconds after ending, then automatically dismisses
Examples:
The dismissal policy applies to both programmatic ending and natural ending (when timers expire).
Stale date
Specifies when a Live Activity should be considered stale and automatically dismissed by iOS.
Note: If you provide a staleDate in the past, it will be ignored.
Relevance score
Helps iOS prioritize which Live Activities to display when space is limited.
Range: 0.0 to 1.0 (default: 0.0)
Live Activities can receive updates even when your app is in the background or terminated, but they cannot execute JavaScript code. For real-time updates from backgrounded apps, use server-side push notifications.
Best practices
Activity lifecycle management
- Always provide meaningful
activityIdvalues for re-binding on app restart - Clean up Live Activities when they're no longer relevant
- Use appropriate dismissal policies based on your use case
Performance considerations
- Keep UI variants lightweight and avoid complex component trees
- Use appropriate relevance scores to ensure important activities are visible
- Set reasonable stale dates to prevent accumulation of outdated activities
User experience
- Provide deep link URLs for navigation when Live Activities are tapped
- Use meaningful compact and minimal variants for Dynamic Island
- Consider dismissal timing carefully - users may want to see final states
