Hello,
Im trying to load an exported game into my WKWebview without any success. Im trying to load the game locally from disk. I am able to do this with a game exported from ctjs so far.
Heres what I am doing.
1. game is stored as a zip on my server
2. app downloads zip and unzips to users document directory
3. I then launch the try launching the game from the directory
Heres what the setup looks like.
Directory of the upzipped game on the phone looks like this:
file:///var/mobile/Containers/Data/Application/37C0D30F-415E-4CF8-8177-FCA0CD3566BD/Documents/6CtBOiFP0ieN4GVQKhQp/
Files are at the root like: index.html, data.json, etc
I open my WKWebview these settings:
let configs = WKWebViewConfiguration()
configs.setValue(true, forKey: "_allowUniversalAccessFromFileURLs") <-- needed for serving locally
let webView = WKWebView(frame: .zero, configuration: configs)
context.coordinator.parent = webView
//....
Task {
let url = await game.downloadZipFile()
let index = url?.appendingPathComponent("index.html")
if let dir = url, let index = index {
webView.loadFileURL(index, allowingReadAccessTo: dir) <-- needed for serving locally
}
}
Again, I can do this with an exported ctjs game and it loads as expected. But when I try to load the example game Glokar in this manner I get the following error.
Now, I've tried this with the HTML5 export. Also, I've tried with the macos export, grabbed the contents of the www folder and also added the usercontentcontroller message handlers for 'C3Wrapper', but still the same error. I do get the messagehandler called with {"type":"ready"}.
Heres screen shots of the promise not handled rejection. Any ideas? :)