rive-ios
rive-ios copied to clipboard
onRiveEventReceived is not called when specifying animationName
Description
Using latest version 5.9.1 and having issues with getting callback on onRiveEventReceived.
Originally, I had issues with rvm.play(loop: .oneShot) and based on this issue, I have added the animationName parameter. While it worked out, I noticed that the onRiveEventReceived is no longer called.
Provide a Repro
class RiveEventsVMExample: RiveViewModel {
@Published var eventText = ""
init() {
super.init(
fileName: "badge_confetti",
animationName: "Timeline", // this line causes the issue
fit: .cover,
autoPlay: false
)
}
func view() -> some View {
return super.view().frame(width: 400, height: 400, alignment: .center)
}
@objc func onRiveEventReceived(onRiveEvent riveEvent: RiveEvent) {
debugPrint("Event Name: \(riveEvent.name())")
debugPrint("Event Type: \(riveEvent.type())")
if let openUrlEvent = riveEvent as? RiveOpenUrlEvent {
debugPrint("Open URL Event Properties: \(openUrlEvent.properties())")
if let url = URL(string: openUrlEvent.url()) {
#if os(iOS)
UIApplication.shared.open(url)
#else
NSWorkspace.shared.open(url)
#endif
}
} else if let generalEvent = riveEvent as? RiveGeneralEvent {
let genEventProperties = generalEvent.properties();
debugPrint("General Event Properites: \(genEventProperties)")
if let msg = genEventProperties["message"] {
eventText = msg as! String
}
}
}
}
-->
Source .riv/.rev file
I can share the .riv file if it is crucial but I need to go through some checks with the team before I can share. I hope this can be easily reproduced with any Rive file.
Expected behavior
onRiveEventReceived should be called regardless of animationName: "Timeline", is specified or not.
Device & Versions (please complete the following information)
- Device: [e.g. iOS Simulator, iPhone 15 Pro Max]
- iOS version [e.g. iOS 17.4]