As described here: Download and Parse · Cocos Creator we can override the built-in download method for any asset.
So what i do:
cc.assetManager.downloader.register('.json', (url, options, onComplete) => {
const oReq = new XMLHttpRequest();
oReq.open('GET', url, true);
oReq.onload = (oEvent) => {
onComplete?.(null, JSON.parse(oReq.response));
};
oReq.send(null);
});
Thats it, nothing else. And this code not working on native platforms. I am getting errors like this:
Simulator[] nil host used in call to allowsSpecificHTTPSCertificateForHost
After that i just opened cocos-engine/download-file.js at 793ed1e41a1e981ef927cb5ecccb6f051f942b50 · cocos/cocos-engine · GitHub
and copied the code from downloadFile
method in my function.
This is also not working on native platforms.
So what should i do to fix this?