Okay - well for the JSON file... not sure, still waiting on @amihanya or other feedback. Maybe check Apple permissions. Or ask Apple why it works on other devices and not theirs ;-).
Load images? Like from the users files?
Save them? Like next time the app is opened they are there?
The ZIM Loader() can load files from the user's device. You could then use the loader.save() to save any changes back to the users device.
When I load with Cordova it works but then it's not found in ZIM.
If I can use the Cordova code then when I get the path of the image save it in ZIM:
var filePath = cordova.file.applicationDirectory + mainData.gameAssetsFolder + nameImage;
readImageFile(filePath, function (content) {
if (content) {
//
}
});
// Define readImageFile function
function readImageFile(filePath, callBack) {
window.resolveLocalFileSystemURL(filePath, function (fileEntry) {
fileEntry.file(function (file) {
var reader = new FileReader();
reader.onloadend = function () {
console.log("Successful read file");
if (callBack) callBack(this.result);
};
reader.readAsDataURL(file); // Use readAsDataURL to handle binary data as a base64 encoded string
}, function(error) {
console.error("File operation error: " + error.code);
callBack(null);
});
}, function(error) {
console.error("File operation error: " + error.code);
callBack(null);
});
}
In simple IOS ZIM load work well.
on Cordova we didnt try that in last year.
I think its somting to play with the Permissions and the Path of the folder
True, at first it failed without returning anything, then I gave permissions and now it does enter the function but returns null.
And I tried all the options of the path and it didn't work.
I really don't know what else it could be. No one has tried cordova with ZIM on ios
new Frame(FIT, 1024, 768, light, dark, ready, ["loading.json", "loading.png"]);
function ready() {
new Label(asset("loading.json").test).loc(100,100);
new Pic("loading.png").center();
}
With the loading.json file being:
{"test":"loading test"}
And both this file and the loading.png are in the same directory as the html file. Also... try a couple different png files just in case it is corrupt.
F.loadAssets("https://zimjs.com/test7/loading.json");
F.on("complete", ()=>{
new Label(asset("https://zimjs.com/test7/loading.json").test).loc(100,100);
new Pic("https://zimjs.com/test7/loading.png").center();
})