After receiving a valid JSON from the server, an error message appears in Chromium:
"Uncaught SyntaxError: Unexpected identifier", source: (1)
Upon investigating, it seems that when calling the method below:
stringBuilder.append("javascript: javascriptBridge.getHandlers().showPost('");
stringBuilder.append(e.getData());
stringBuilder.append("');");
webView.loadUrl(stringBuilder.toString());
The issue arises with the e.getData()
function, which contains the valid JSON data. It appears that something within the JSON is being misinterpreted as a JavaScript function parameter.
javascriptBridge.registerHandler('showPost', function (data) {
alert('showpost'); //this is not called
});
It's puzzling because this method has worked successfully for other types of data and even for JSON in the past. Any suggestions on how to resolve this issue? There may be a specific character causing this unexpected behavior.