WKWebview evaluateJavascript

Hi there forum,

I'm having an issue with the following javascript xhr request only in iOS 14 (it works in iOS 13 and lower):


Code Block language
     let script = """
    var xhr = new XMLHttpRequest();
    xhr.open('GET', '\(absoluteUrl)', true);
    xhr.responseType = 'blob';
    xhr.onload = function(e) {
      if (this.status == 200) {
        var blob = this.response;
        var reader = new window.FileReader();
        reader.readAsDataURL(blob);
        reader.onloadend = function() { window.webkit.messageHandlers.readBlob.postMessage(reader.result);
        }
      }
    };
    xhr.onerror = function(e) {
      console.log(e.target)
    }
    xhr.send();
    """
     
    self.webView.evaluateJavaScript(script, completionHandler: nil);


The absoulteUrl in question here looks like this: blob:http://{my-host-domain}/1cbb6855-2402-4411-adc7-f889cdd5b78a
This blob is always on the same domain that I am navigating to but I've also tried adding app-bound domains to no avail.

Is there something about iOS 14 that would make this script break?

Hi, I face the same problem here, any feedbacks regarding this issue ?
I am facing the same issue, I was using a similar approach (using fetch instead of XMLHttpRequest) to get the blob. It works in iOS 12 and 13 but is broken in iOS 14.

It appears that a change in iOS 14 has broken the ability to download blob resources when using WKWebView.

Here is a link to the approach that uses JS fetch:
https://developer.apple.com/forums/thread/108394?page=1#653466022

Is there a way to get a blob resource when using WKWebView in iOS 14? Does anyone have a fix for this?
WKWebview evaluateJavascript
 
 
Q