iOS15 ,WkWebview,evaluateJavaScript

Execute java script in ios15 system, h5 developers cannot get the value on the window. System below ios15 is normal

Answered by devvungle in 684493022

What will happen to existing apps who use evaluateJavascript (with custom property added to window object) and upgrade to iOS 15? Won't they stop working?

I have meet the same error. Maybe the WKWebview function "evaluateJavaScript:" occurs some problems. Try another way to inject your code to solve this problem. For example

     WKUserScript *script = [[WKUserScript alloc] initWithSource:@"window.exeData = '1'" injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
    [webView.configuration.userContentController addUserScript:script];

Hope this way can help you.

Accepted Answer

What will happen to existing apps who use evaluateJavascript (with custom property added to window object) and upgrade to iOS 15? Won't they stop working?

-(void)webView:(WKWebView*)webView didFinishNavigation:(WKNavigation*)navigation

After webVIew is loaded and then use evaluateJavascript to load custom properties can also be successful

iOS15 ,WkWebview,evaluateJavaScript
 
 
Q