Overview
The Rive iOS Runtime supports two types of events:- General Events: Custom events with properties you define
- Open URL Events: Special events for opening URLs with target specifications
Event Types
RiveEvent Base Class
All events inherit fromRiveEvent, which provides:
RiveGeneralEvent
General events are custom events you define in the Rive editor:RiveOpenUrlEvent
Special events for opening URLs:Setting Up Event Handling
Implementing the Delegate
To receive events, implement theRiveStateMachineDelegate protocol:
Handling General Events
General events can carry custom properties:Handling Open URL Events
Open URL events are designed for navigation:Complete SwiftUI Example
Here’s a full example showing event handling in SwiftUI:UIKit Example
Event Timing
Thedelay() method returns the time delay in seconds since the event was fired:
Common Event Properties
Common property names used in events:Best Practices
- Event Names: Use descriptive event names in the Rive editor that match your app’s domain
- Type Checking: Always check event types before casting to specific event classes
- Property Keys: Document property keys used in your events for consistency
- Error Handling: Safely unwrap optional properties to avoid crashes
- Threading: Event callbacks are called on the main thread, safe for UI updates
- State Management: Use
@Publishedproperties to propagate event data to SwiftUI views
Event Use Cases
User Interactions
Navigation
Game Logic
Analytics
Creating Events in Rive
In the Rive editor:- Select a state or transition in your state machine
- Add an event in the Inspector panel
- Choose event type (General or Open URL)
- Set event name and properties
- Configure timing and conditions
See Also
- State Machines - Working with state machines
- Data Binding - Alternative for data communication