Aplication in cordova ios

Hello, I am writing an application in ZIM and with cordova i build ios and cordova.
this my code:


I have a problem, in ios frame.asset it returns me an empty object)(null), like it can't find the files

Do you have any idea what the problem could be, I've been stuck on this for a long time.

Just heading in to a conference... is it working in android and desktop but not iOS? Perhaps try a "./assets/etc."

And welcome to the forum!

@amihanya (or anyone) have you had an issue with JSON files on apple iOS? I do not think we have had any issues, but have not tried in a while...

Even after I changed ./ an empty object is still returned

Do you see data when on Android - or desktop?

Yes, it works on Android and safari

If I load the images through Cordova is there a way to save it in ZIM?
Image 26-06-2024 at 22.23.jpg

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

We used it with PhoneGap Build... but did not access JSON with it or a text file. Then we went to PWA rather than Cordova.

ZIM uses CreateJS PreloadJS for its loading. So you can look to see if anyone has had an issue with PreloadJS / CreateJS on Cordova.

Is it loading your images and sounds correctly? Try a plain text file:

new Frame(FIT, 1024, 768, light, dark, ready, "myText.txt");
function ready() {
    new Label(asset("myText.txt")).center();
}

Here is our quick test of this - works on desktop with simple message in myText.txt
https://zimjs.com/test7/text.html

This will see if it is the loading or something to do with the JSON.

txt file is success but json and png don't work.
this error:

Let's try a very simple case:

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();	
}

This is at https://zimjs.com/test7/loading.html

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.