'Saving file from Chrome IOS is not working?
I am trying to make this work, I want to be able to download a file from a website, I'm using an NPM package called file-saver and also tried a solution in one of the answers here, yes it works but the problem is it is not working on chrome iOS, for some reason anyone found out what could be the solution to this ? Is it that chrome is so strict it doesn't allow you to download anything?
const saveLocalStorage = () => {
// Grap the whole ls object and save
const ls = JSON.stringify(localStorage);
// Using file Saver NPM
//FileSaver.saveAs(new Blob([ls]), 'Plan.Online', { autoBom: true });
const downloadBlob = (fileName: string, blob: any) => {
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.target = '_blank';
link.download = fileName;
document.body.appendChild(link);
link.click();
};
const blob = new Blob([ls], {
type: 'text',
});
downloadBlob('Data.txt', blob);
};
Solution 1:[1]
If your app works in iOS Safari, but not in iOS Chrome browser, the issue may be how Apple has Chrome configured.
From this reference
Google Chrome is now available for the iPhone and iPad, but before you get too excited, you need to realize that it isn't Chrome at all. It's Apple's Safari with a 'chrome' interface. The actual browser, the rendering, and javascript engine is 100% Apple Safari.
The reason is simple. Apple wants control and force people to create native apps, and are thus limiting the performance of web apps in third party apps. ... This is purely anti-competitor behavior that limits choice and forces people to create native apps.
When I write Progressive Web Apps (PWA), I have to tell my users that they have to use the OS native browser. Android=Chrome, iOS=Safari. Period. No substitutes. Apple clearly doesn’t want universal browser code functionality.
Note: I know that reference above is pretty old. But as far as I know the essence of the facts still stand. Note: I'm coming at this from the perspective of developing Progressive Web Apps. The one feature I really rely on is the ability to "Save link to home page". And that is just not available in Chrome on iOS, even now. Not sure you have exactly the same use case.
Solution 2:[2]
i found this discussion may related! a chrome engineer says: "Ah, that's because Chrome on iOS hasn't yet adopted the new WKDownload delegate methods, but this is currently being worked on (see crbug.com/1252380)"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | zipzit |
| Solution 2 | tyra |
