Image Preloading
This page provides detailed API documentation for Voltra's image preloading system. For an overview of all image handling approaches in Live Activities, see the Images documentation.
Live Activities have strict size limits (4KB per update), which makes displaying remote images challenging. The image preloading API downloads images to shared App Group storage, making them available to both your app and Live Activities.
Overview
The image preloading system works by:
- Downloading images from URLs to App Group shared storage
- Validating that images are under the 4KB ActivityKit limit
- Making images available to Live Activities via the
assetNameproperty - Providing APIs to reload existing Live Activities when new images are available
API Reference
preloadImages(images: PreloadImageOptions[]): Promise<PreloadImagesResult>
Downloads images to App Group storage for use in Live Activities.
Example:
reloadLiveActivities(activityNames?: string[]): Promise<void>
Reloads Live Activities to pick up newly preloaded images. If no activityNames are provided, all active Live Activities will be reloaded.
clearPreloadedImages(keys?: string[]): Promise<void>
Removes preloaded images from App Group storage. If no keys are provided, all preloaded images will be cleared.
Usage in Live Activities
Once images are preloaded, reference them using the assetName property:
Size Validation
ActivityKit enforces a 4KB limit per Live Activity update. Images are validated both before and after download:
- Content-Length header: If available, images larger than 4KB are rejected before download
- Actual size: After download, the actual data size is validated
- Image validation: Ensures the downloaded data is a valid image format
Images that exceed 4KB will result in a preload failure with a descriptive error message.
Error Handling
The preloadImages function provides detailed error information:
Common Error Messages
"Image 'key-name' is too large: 5120 bytes (max 4096 bytes for Live Activities)"- Image exceeds 4KB limit"Invalid image data for 'key-name'"- Downloaded data is not a valid image"HTTP error: 404"- Server returned an error status code"App Group not configured"- Missing App Group configuration in the config plugin
Configuration
Image preloading requires App Group configuration in your Expo config plugin:
