[BUG] Ti.App.fireEvent() expects a string as the second arg on iPhone, and an object on Android
Using fireEvent() to send messages to a web view which is listening to the events. The events weren't being delivered on iPhone until I manually JSON.stringify()ed the second arg.
Edit: actually, even if I pass a string in to fireEvent(), the event listener only receives a single arg of the form {type: "theEventName"}. So am I right that passing data to a web view is just not possible on the iPhone at the moment apart from with evalJS hacks?
3 Answers
-
I dove into the titanium_mobile source code and figured it out. The problem is that function attributes are not stripped from the object before they are jsonified, so if the object has any prototype-inherited methods, invalid json is generated.
[DEBUG] fire app event: showQuestion with { "__repr__" = <KrollCallback: 0x527e050>; question = "foo"; } [DEBUG] json str={"type":"showQuestion","question":"foo","__repr__":}
-
did you file this in lighthouse?
https://appcelerator.lighthouseapp.com/dashboardrocksteady,
danno~ -
When I asked marshall_law on IRC where I should file bugs, he told me to file them here.