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.

Not loading on my android phone

Oh no - we had not uploaded the JSON and PNG. Oops. Thanks for letting us know. @ayala - please note.

problem in slate, json is not loading

Did you preload it?

ok now it works

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

i made the zapp here

so can it be used for input on a second screen as you discribe into the video on
https://danzen.com/expo/artificialintelligence.html

see


as this was a question

https://forum.zimjs.com/t/how-could-you-do-it-controlling-a-second-screen/1788

so for a quiz solution you can make of an https://opensheet/googlesheetnumber/tabname a jsonfile that is online showing each question by setting a new question each time on the same record as inpit for the second screen to show the question..

I'll make an example tommorrow

thanks for the idea @abstract