I'm trying to inject to my webview the below script:
self.webView.evaluateJavaScript(
"""
const OldNotify = window.Notification;
const newNotify = function(title,opt) {
var obj = {
title: title,
content: JSON.stringify(opt)
};
console.log(obj);
return new OldNotify(title, opt);
};
newNotify.requestPermission = OldNotify.requestPermission.bind(OldNotify);
Object.defineProperty(newNotify, 'permission', {
get: () => {
return OldNotify.permission;
}
});
window.Notification = newNotify;
"""
) { result, error in
print(error)
print(result)
}
}
But i get this error
Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type}