Ensure evalAsync behaves the same across platforms
jonatansberg opened this issue · 0 comments
jonatansberg commented
Background
The behavior of evalAsync differ between platforms. In order for things to work cross platform you need to wrap your call in an IIFE and make sure to skip the final semicolon.
webView.evalAsync('(function(){ return { some: "object" }; })()', function (res) {
var obj = res && JSON.parse(res);
});
Todo
- Return JSON strings on iOS (instead of just freaking out for non string values)
- Handle calls that are not wrapped in functions on Android
- Be tolerant of syntax stuff (i.e. trailing semicolons)