HTML5 localStorage space limit on iPad Safari - ios

To clarify I'm referring to the key/value localStorage pairs, not Web SQL DB or IndexedDB.
Is it strictly a 5MB limit for the iPad, or is it true that it's unlimited but it will ask the user to allow/deny once you exceed 5MB?
I'm hoping to use localStorage to store a large amount of data and so is important that it's unlimited.

Have a look at how the Financial Times web app deals with it:
http://apps.ft.com/ftwebapp/
On installation it detects the limit and then provides instructions for the user to manually increase their limit to 50MB using the Settings app.
If there was an easier/automatic way to do this, I'm sure they'd use it.

Yes, it's the same limit for iphone and other apple devices as well because of how Safari implemented localStorage. Take a look at this
Limit of localstorage on iPhone?

Safari mobile is limited at 50mb, if you try to write to local storage over the storage quota it will throw an exception. There is no way to check how much space is remaining, you simply have to try to write and catch the exception. Pretty terrible.
Below are some articles on the limits of the various storage types. The conclusion is Safari mobile sucks.
https://developers.google.com/web/fundamentals/instant-and-offline/web-storage/offline-for-pwa
https://en.wikipedia.org/wiki/Web_storage
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/bg142799(v=vs.85)#_objmodel:
https://developers.google.com/web/fundamentals/instant-and-offline/web-storage/offline-for-pwa
https://www.html5rocks.com/en/tutorials/offline/quota-research/

I know you are looking for localstorage key/value pairs. Just like myself. I tried a native solution and apparently my iPad had 2.5 MB only for localstorage. So I switched to locaForage which is a IndexedDB (+more) wrapper in a very similar to localstorage api. It doesnt have these limitations of localstorage.

Related

iOS UIWebView - caching assets in native apap

I am evaluating a project that was originally targeted to be just a PWA using React and Redux.
The application needs offline support though, and needs a sizable amount of media assets (images and videos) to be available offline.
Since the service worker storage limit is just 50MB, this is not feasible for iOS.
I have toyed with the idea of using a native app wrapper that handles the storage of the media files, with most of the app remaining a Redux/React implementation.
Is there a good way to expose such assets from to the UIWebView from the native app? Or are there other common approaches for this situation?
First off all you should try to cache only that assets which are necessary for your PWA.However still if you want to store large files I would suggest you can go with IndexDB API.
IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data. While Web Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solution.
Why IndexDB?
When quota exceeds on IndexedDB API, the error calls the transaction's onabort() function with Event as an argument.
When a browser requests user a permission for extending storage size, all browsers call this function only when the user doesn't allow it, otherwise, continue the transaction.
If you want know about other possible DB I would suggest you to go through this link
https://www.html5rocks.com/en/tutorials/offline/quota-research/

Mobile Safari LocalStorage Limit

I'm developing this cordova app which is required to save some data locally in case there is no internet connection available. This dataset also contains images in the form of a base64 string. Turns out I can roughly create about 7-8 items before my localstorage starts running out.
There seems to be a 5MB limit on almost all of the local storage techniques for mobile safari. After doing some googleing I couldn't find much concrete information on how to bypass this limit, as some apps are reported to have found a way around this restriction.
I'm currently using key value storage with that comes with Quasar Framework. (https://quasar-framework.org/components/web-storage.html) I'd love to keep using their API but if it's necessary I could always change some storage related code.
Is there a way to increase the size? I've ready about prompting the user for a storage increase but it's not explained anywhere specifically.
Thanks,
I had the same problem some time ago and i found no solution for localstorage.
This article is interesting if you want more details about localstorage and its limits : https://www.raymondcamden.com/2015/04/14/blowing-up-localstorage-or-what-happens-when-you-exceed-quota
To exceed this limit, I used IndexedDB which allows me to store much more data and especially to better store them.
Raymond CAMDEN has written a very interesting article that will guide you : https://www.raymondcamden.com/2015/04/17/indexeddb-and-limits
If you want to use IDB but are afraid of its complexity, there is Dexie.js which simplifies its use : http://dexie.org/
You may be able to use more browser storage by using a different API such as IndexedDB. https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria

Temporarily storing data on iPad without WiFi

I am developing an application where the user will not have WiFi and needs to save their data until they have WiFi and then upload their data. Is there any temporary uploading programs I could use?
Why not use the localStorage? It's becoming more reliable. I've used it in my own applications and the API is easy enough to pick up.
When using it with the iPad TumbleCow has one or two things to keep in mind.
Yes, the storage-limit is still 5Mb. Since characters are stored UTF16, only 2.5M characters can be stored in localStorage.
In contrast to other localStorage implementations, localStorage.setItem() doesn't delete any previous items with the same key before storing the new item. In other words: When overwriting an item, one should always call localStorage.removeItem() before calling localStorage.setItem(), or you'll quickly run out of space.
Is localStorage reliable on an iPad?

Safely storing data in a HTML5 iOS application - are localStorage / WebSQL / IndexedDB appropriate?

I'm writing a HTML5 application that I want to release on the iOS app store. Either using PhoneGap or wrapped in a UIWebView control.
I'm a bit confused about what options I have in terms of storing data for my application.
Are using localStorage, WebSQL or IndexedDB technologies appropriate for storing application data in this type of application? I will be storing JSON and XML data.
Keep in mind, if the user inadvertently deletes this data then they will have lost their work, which obviously I don't want to happen.
I understand that the only real way to alleviate this risk is to sync the data to the "cloud" or other online system - I can do that in a future release, but not right now. Initially I just want to store the data locally if that is a reasonable stable way to do things.
From what I understand, when clearing the cookies the browser will also clear any localStorage data. So that rules that out, as I can see users doing that by accident.
WebSQL looks pretty good - the user can't inadvertently delete it on iOS. They would actually have to go into the browser settings and delete the database manually.
But the downside of WebSQL is that it may not be supported in the future from what I've read.
With IndexedDB, I am not clear when that data gets cleared. Will it also removed when cookies are deleted, or does the "databases" option in the Safari settings control this?
Is IndexedDB the better solution, as it will have better support than WebSQL in the future?
Are there other solutions that are more appropriate that I am not aware of?
If you are wrapping in PhoneGap (or AppMobi - where I work), you're data is segmented to that app. A user can not go into Safari and clear the browser data/cookies and have that happen in your app. The only way they can delete it is by deleting the app.
I don't think IndexedDB is avaiable. Window.localStorage is (5 megs but I think it can grow), which is a KVP system.
I don't see them dropping WebSQL for a few years. The HTML5 spec isn't even ratified yet, so things could change again.
Since you are just storing strings, you can check out libraries like Lawnchair that will use different adapters (localStorage, WebSQL, etc) to store your data how you want since it appears you do not have complex data sets.
localStorage (aka Web Storage) and WebSQL are supported on all current mobile browsers except Opera Mini.
WebSQL, however, is considered "dead" as of November, 2010. The spec has a big fat "beware" label on it. It reads:
This document was on the W3C Recommendation track but specification work has stopped. The specification reached an impasse:
all interested implementors have used the same SQL backend (Sqlite),
but we need multiple independent implementations to proceed along a
standardisation path.
As far as mobile browsers, IndexedDB is -- as of Dec. 2013 -- only supported in Android 4.4 (meaning no iOS Safari, Opera Mini/mobile or widespread Android Browser support).
See caniuse.com for the latest compatibility tables.

HTML5 Ipad Error while downloading large numbers of pictures

I want to develop an offline html5 website with a large number of pictures (10 000).
The problem is that during the downloading process when safari ask me to increase the cache limit it stop the download and i need to start it again.
It's possible to make such application in html5 on a ipad ? can we breach the offline cach limit :) ?
Thks a lot in advance !!!!!!
The limit is set inside the browser itself, typically at 5MB. Currently, as far as I'm aware, the only way to increase it is by the user actually doing it via the browser menu.
There might be a way of increasing it programmatically, I don't know, but you would most certainly have to ask the user's permission to do so.
I also think it's a bit much to be expecting someone to allow 10k+ images to be stored on their system, that could be huge.

Resources