Server-side updates
Voltra supports server-side updates for Live Activities through Apple Push Notification Service (APNS). This allows you to update Live Activities even when your app is in the background or terminated.
Configuration
Expo Config plugin setup
To enable server-side updates via push notifications, you need to configure the Voltra plugin in your app.json or app.config.js:
Minimal configuration (push notifications only):
Full configuration (with App Groups for event forwarding and shared images):
Note: The groupIdentifier is optional. It's only needed if you want to forward component events (like button taps) from the Live Activity extension to your JavaScript code, or if you need to share images between your app and the extension. Push notifications work perfectly fine without it.
Xcode configuration
The Voltra config plugin automatically handles most of the Xcode configuration for you:
- Adds the
aps-environmententitlement (set todevelopmentfor debug builds) - Configures Info.plist flags to enable push notification integration
- Sets up App Group entitlements (if
groupIdentifieris provided)
However, you'll still need to complete a few manual steps:
-
Provisioning Profiles: Ensure your app has proper provisioning profiles configured in Xcode with push notification capabilities enabled.
-
APNs Certificates: Set up APNs authentication certificates or keys in your Apple Developer account. You'll need these to send push notifications from your server.
-
Capabilities: Verify that Push Notifications capability is enabled in your app's target settings in Xcode.
For detailed information about setting up push notifications in iOS, refer to Apple's official push notification documentation.
Server-side rendering
Voltra provides a server-side API that allows you to render React components into JSON payloads that can be sent via APNS. The same Voltra components you use in your app work on the server.
Using the server-side API
Import the server-side rendering functions from voltra/server:
The renderLiveActivityToString function accepts a LiveActivityVariants object and returns a compressed, base64-encoded JSON string for your APNS payload.
APNS payload format
When sending push notifications to update Live Activities, you need to structure your APNS payload correctly. For detailed information about APNS payload structure, see Apple's official ActivityKit push notification documentation.
You can also use Appleās CloudKit - Push Notifications tool to send test push notifications during development.
Required APNS headers
Replace <your.app.bundle.id> with your app's bundle identifier (e.g., com.example.myapp).
Payload structure
For updating an existing Live Activity:
For starting a Live Activity remotely (iOS 17.2+):
Key fields:
aps.event: Set to"update"for updating an existing Live Activity, or"start"for push-to-start (iOS 17.2+)aps.content-state.uiJsonData: The JSON string returned byrenderLiveActivityToString, embedded as a string value eg.ixOAeyJ2IjoxLCJscyI6eyJ0IjowLCJjIjoiSGVsbG8sIHdvcmxkISJ9fQM=aps.timestamp: Unix timestamp in seconds (required for Live Activities)aps.attributes-type: For push-to-start, must be"VoltraAttributes"aps.attributes.name: For push-to-start, a user-defined name for the activity (can be any string you choose)aps.alert: Required field for push-to-start
ActivityKit enforces a strict payload size limit of approximately 4 KB. Keep your UI JSON minimal to stay within this limit. Avoid deeply nested component trees and excessive styling to ensure your payloads fit within the constraint.
Getting push tokens
Voltra provides specialized push tokens that are different from regular device tokens. These tokens are specifically designed for Live Activity push notifications and should be used instead of standard device tokens.
Tokens for updating Live Activities
To update existing Live Activities, use activity push tokens:
Tokens for starting Live Activities remotely
To start Live Activities remotely (push-to-start), use push-to-start tokens:
Use only Voltra-provided tokens, which are specialized for Live Activity push notifications and different from regular device tokens. Update tokens are tied to specific Live Activities, while push-to-start tokens are for starting new activities. Update tokens are provided when Live Activities are started and may change during the activity's lifecycle. When sending notifications via APNS, use these push tokens as the target device token to route notifications to the correct Live Activity or device.
Handling background execution
When Live Activity tokens change or need to be refreshed, iOS may wake your app in the background to deliver new tokens. The app has a limited window of time (typically around 30 seconds) to handle the event and communicate with your server before iOS may suspend or terminate the background process.
Detecting background execution
Use the isHeadless() function to determine if your app is running in the background:
Optimizing for background execution
When the app is launched in headless mode for token handling, do not mount your main app component to avoid excessive resource usage that could cause iOS to terminate the app before token updates are processed.
