I'm using WebCrypto library to decrypt the data but it's not working on iOS 15 Its working fine in iOS 14
I have checked the evaluateJavaScript function of webView is throwing error
Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=27,
WKJavaScriptExceptionMessage=TypeError: undefined is not an object (evaluating 'y.importKey'), WKJavaScriptExceptionColumnNumber=8260,
WKJavaScriptExceptionSourceURL=undefined, NSLocalizedDescription=A JavaScript exception occurred}
I stumbled also upon this, the new IOS15 behavior did break our code too. Apparently Apple changed the semantics of evaluateJavaScript
:
depending on when the following code has been called the new function does not appear in the JS namespace if it is called too early.
[_webview evaluateJavaScript:@"function foobar() {console.log('in foobar');}" completionHandler:^(NSObject* res,NSError* err) {
}];
if this code is called prior to
[_webview loadRequest:req];
then it doesn't have any effect anymore (But no error is raised at that point..the function lands in nirvana ). The solution is to add such code as user script as pointed out at https://developer.apple.com/forums/thread/684020
WKUserScript *script = [[WKUserScript alloc] initWithSource:@"function foobar() {console.log('in foobar');" injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
[_webview.configuration.userContentController addUserScript:script];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With