Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onRiveEventReceived is not called when specifying animationName #294

Open
aj-cooler opened this issue Mar 14, 2024 · 0 comments
Open

onRiveEventReceived is not called when specifying animationName #294

aj-cooler opened this issue Mar 14, 2024 · 0 comments

Comments

@aj-cooler
Copy link

aj-cooler commented Mar 14, 2024

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant