WKWebView fails to open .doc file

I'm currently using a WKWebView to load certain types of documents via loadRequest, but I've recently been running into an issue with .doc files doing this:

static NSString *customScheme = @"customscheme";

@interface WordDocWKSchemeHandler : NSObject <WKURLSchemeHandler>
@end

@implementation WordDocWKSchemeHandler {
    NSData *_data;
    NSString *_mimeType;
}

- (instancetype)initWithData:(NSData*)data mimeType:(NSString*)mimeType{
    self = [super init];
    if (self) {
        _data = data;
        _mimeType = mimeType;
    }
    return self;
}

- (void)webView:(WKWebView *)webView startURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask {
    NSURL *url = urlSchemeTask.request.URL;
    if (![url.scheme isEqualToString:customScheme]){
        return;
    }
    NSURLResponse *response = [[NSURLResponse alloc] initWithURL:url MIMEType:_mimeType expectedContentLength:_data.length textEncodingName:@""];
    [urlSchemeTask didReceiveResponse:response];
    [urlSchemeTask didReceiveData:_data];
    [urlSchemeTask didFinish];
}

- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask{
    //empty
}
@end
- (void)_setupWebViewPropertiesAndConstraints{
    _webView.navigationDelegate = self;
    _webView.hidden = YES;
    [self.view addConstrainedSubview:_webView];
    [self.view addConstraints:[_webView constraintsForFillingSuperview]];
    self.container.showsLoadingIndicator = YES;
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
        WKWebViewConfiguration *docConfig = [WKWebViewConfiguration new];
        WordDocWKSchemeHandler *schemeHanlder = [[WordDocWKSchemeHandler alloc] initWithData:_content.data mimeType:_content.contentType];
        [docConfig setURLSchemeHandler:schemeHanlder forURLScheme:customScheme];
        //Setup webview with custom config handler
        _webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:docConfig];
        
        [self _setupWebViewPropertiesAndConstraints];
        
        NSURL *customURL = [NSURL URLWithString:[NSString stringWithFormat:@"\%@:/",customScheme]];
        [_webView loadRequest:[NSURLRequest requestWithURL:customURL]];
}

The mimeType is correctly being resolved to "application/msword" but any time we try to load this the navigation fails:

-(void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {

The error message here is OfficeImportErrorDomain Code=912.

I've tried this on both a simulator and actual device on iOS 17 and 16 and this always fails. I've also tried turning the data into a base64 string and loading it that way and this also fails.

Any advice here would be appreciated. It seems like this used to work at some point but no longer works.

WKWebView fails to open .doc file
 
 
Q