I'm trying to set my app up to get a callback from a JS function. I'm seeing a number of different responses and configurations out there, and I think I'm close, but something is off.
This is the error I'm getting from the JS:
TypeError: undefined is not an object (evaluating 'window.JSInterface.writeCarKey')
And this is the JS Code:
function writeToNative(id, description, key) {
window.JSInterface.writeCarKey(id, description, key); }
I've tried variations of this in my app:
let contentController = WKUserContentController()
contentController.add(self, name: "writeCarKey()")
all to no avail.
The above code is working in an Android app, but from the various responses to this kind of issue I'm seeing, it looks like I need this in the JS code?
window.myApp.writeCarKey = function() {
window.webkit.messageHandlers.writeCarKey.postMessage("1", "K", "CAR"); };
Is it just this that I'm missing in the JS code?
Aucun commentaire:
Enregistrer un commentaire