我在应用程序中创建了一个webview和一些js绑定。
为了安全起见,我将js桥函数包装在try catch中。
但是,我不知道js catch函数捕获了什么。
由于错误是随机发生的,因此我通过GA发送错误,但未设置事件值。
try {
price = JsBridge.getProductPriceString('something wrogn');
} catch (e) {
ga('send', 'event', 'Error', 'Exception', e && e.toString());
console.log("getPriceString", e);
alert("get price string error:", e);
}
我认为我可以从Android Java方面进行调查。
但是我不知道Android js绑定何时会触发js catch功能?
答案 0 :(得分:1)
您可以像在Android中一样使用调试
Log.d("tag", "exception")
如果您使用alert
并且console.log
在Android中不能直接使用