is localStorage on iPad Safari guaranteed to be persistent? - ios

I've seen differences of opinion across the web on this. It has been said that starting with iOS 5.1, local data storage for HTML5 content on the iPad is no longer guaranteed to be persistent, however on Apple's current Safari developer pages (https://developer.apple.com/technologies/safari/html5.html), offline persistence is suggested to be guaranteed.
Does anyone have any recent experience with this subject and able to comment on how reliable the database features of HTML5 are with Safari on iPad?

This will probably be enough information:
The w3c spec of localStorage is:
The second storage mechanism (note: localStorage) is designed for storage that spans multiple windows, and lasts beyond the current session. In particular, Web applications may wish to store megabytes of user data, such as entire user-authored documents or a user's mailbox, on the client side for performance reasons.
And on the Apple page:
Safari supports the latest HTML5 offline data storage features. Your application can store its information on the local machine using either a simple key/value-based data store, or a robust SQL database. The data is stored locally and persists across launches of Safari so your application doesn’t need a network connection to access the data, improving startup time and overall performance.
And searching Google (and Yahoo! because of some anti-google freaks) gives me:
In iOS 5.1 Apple have moved the location of localStorage files into a Caches folder which is subject to occasional clean up, at the behest of the OS, typically if space is short. It is likely that Apple have done this to stop localStorage being backed up to iCloud.
localStorage not accessible in IOS-6 Safari
I am not able to access localStorage in Safari (IPad with IOS-6).
For example, the following code is working fine in Windows on all browsers and on (iPad with iOS-5) but not in iOS-6:
localStorage.setItem("var","5");
alert(localStorage.getItem("var"));
Answer:
I was able to fix the issue by turning off private browsing on the iPad. I came across the solution from the reference : https://github.com/cloudhead/less.js/issues/312#issuecomment-2994845

Yes, Apple cleans up localstorage when the device is low on storage space. (I actually tested this and confirm it with a certainty).

Related

How much data can I store in IndexDB from a mobile phone using a PWA

I have a PWA designed in Ionic and we are using it to take pictures. However the requirements is that it needs to work offline so we are storing these pictures in IndexDB.
However I have been unable to track down how much storage we will have access to in IndexDB and am concerned it will only be around 50MB or so. The the customer potentially wants to store 100 images or more offline and when it gets back to wifi it will start sending up to a remote API.
Is there any information on storage capability for indexDB when a PWA is run on a mobile device either IOS or Android?
I have seen some posts that but mainly talk about storage of the javascript files where this is actual data captured while the app is running.
NOTE: Individual images will be no more than 2-3MB each in size.

PWA on IOS and offline storage

We looking to develop an "App" which would have the ability to record the details of a damaged car for assessors. The idea is that a small number of assessors would have company iPads. Then when car is damaged and returned to the car yard they can visit take photos, enter some details and then upload them into the main system later. Some of the car yards may be in areas that do not have internet coverage, so offline capability is required.
Our initial thoughts were to develop an IOS App for installation on a small number of company iPads. The App could access the camera to take photos and then when the device has internet access upload the photos to the main system. However this solution could prove too costly (regarding development costs) for the customer.
I have read about PWAs and caching data, but the caching seems to be for offline read access.
If we installed chrome on an iPad and then installed a PWA then presumably
The PWA could store pictures up to 128GB * 6% = 7.68GB?
If stored using the File System API then (as long as there is plenty
of space on the system) the data will be persisted (my understanding is there is no time limit)? Or would a different type of storage be more suitable.
The offline data is obviously important (may be required in court) so are there any other concerns around persistence & stability before the images are uploaded to the main system?
Note we would prefer to use iPads (as the customer would prefer these) but we could consider other platforms.
At this stage I am really trying to find out if a PWA accessing the offline storage is likely to be feasible, practical and stable on the platform?
Firstly, iOS restricts third party web browsers (or any app that displays web pages) to using its own engine - installing Chrome on an iPad will not enable access to any web APIs that iOS/Safari doesn't already support.
So in particular:
File System API is not available on iOS, even if you're using Chrome
Cache API has a storage limitation per website of 50MB
IndexedDB has a storage limitation per website of 500MB or half the device's free space (whichever is smaller)
PWAs and their cached data are automatically wiped from devices if not used for a few weeks
the "navigator.storage" API for requiring durable data is not support on iOS, even if you're using Chrome or Firefox.
My first thought would be that if you are only going to support iPads and indefinite offline storage is a requirement, you are probably best of with a native application. Keep in mind that for this kind of application you would need the Apple Enterprise Program, which is more expensive than the regular Developer Program.
However, if you do want to use a PWA, your best bet for local storage would be the IndexedDB. As per the comment by skybondsor, browsers do indeed limit and possibly evict data after a while, according to ADM webdocs.
But reading your question, I get the sense that you do not really need persistent local storage, but rather a method ensuring that your data will eventually end up on the server. You can accomplish this by exploiting the Background Sync methodology. This allows your application to delay the upload to when a stable internet connection is available.

iOS11 Safari: Add to Home-screen localstorage lifecycle

I found Home-Screen app localstorage is not deleted by Safari clear cache.
It seems to be persistent storage, but I cannot find any documents about this.
My Question is
Is there any document about this behavior?
Home-Screen app localstorage lifecycle. when will be cleared? how to clear?
Can I use localstorage to save persistent token for PWA?
There is localstorage tester here
Local storage is not cache, it is persistent storage. You can add or delete values manually.
Apple's documentation says the following:
Safari supports the latest HTML5 offline data storage features. Your
application can store its information on the local machine using
either a simple key/value-based data store, or a robust SQL database.
The data is stored locally and persists across launches of Safari so
your application doesn’t need a network connection to access the data,
improving startup time and overall performance.
This storage is limited to 5 MB and can be cleared if the device is running low on space, but this is the main way to store data on the user's device.
You can learn more about local storage here

How to monitor data usage on iOS from an app?

There are a few similar questions on SO, but none directly answer this question: how can an app programmatically monitor the data usage of other apps?
For instance, at the end of the month, we would like a report that shows Chrome used X MB of data and Yelp used Y MB of data. It seems possible since companies like http://www.onavo.com/ are doing it now.
But our understanding is that apps are sandboxed on iOS and unable to monitor the data usage of other apps?
Thanks!
It isn't legally possible. DataMan Pro tried to do it, and got away with it for a while, but Apple caught them and the app was thrown off the AppStore. It's back now, but without that capability.
Onavo works by setting up a proxy server. It knows how much data a browser uses because the data passes thru their server. It isn't measuring anything on the device; it's talking to their server.

Is it possible to get a unique identifier for an ios device from a browser, in a controlled environment?

This is (a very simplified version of) the scenario with which I am faced:
I have an existing web application which manages jobs. We are now purchasing a number of ios devices (iphones and ipads) and I need the web application to know which specific device (regardless of the user) is updating information through the web application (as well as getting the GPS co-ordinates, but I think I have that covered with the geolocation API).
I have control of all the devices, they will all come to me before being distributed and will return to me periodically, so I can modify/restrict etc., but I can't jailbreak.
I have no experience of ios, but if there is a way to do this without needing an app, that would be the best choice.
You can use HTML5 storage to create and save a GUID the first time user accesses your website and send it with subsequent requests.

Resources