iOS Cellular Data Usage Tracking - ios

I would like to track a systems cellular data usage.
I found some interesting resources. The code in the accepted answer works fine and I'm able to read the bytes downloaded over the cellular network.
But I also found out that the data is reset when the user reboots their device. So, when the user opens up the app, I might (for example) read 200 MB data usage. The app saves this value. If the user closes their app, downloads another 100 MB and then reboots the device, when the app is opened again the counter will read 0 MB. The last saved value is 200 MB. How can I find out that he actually downloaded a total of 300 MB?

You can track data usage while your app is in use. You cannot access download information when your app is not running. iOS prevents it for security reasons. You could save the value of 200MB to NSUserDefaults or another persistent store. Then you could reload that data on app launch.

Related

PWA app - Store images and videos in local storage using Angular 6

I am creating a Progressive web app(PWA) using angular javascript. where I need to store images and videos downloaded from the server.
I have explored on local storage and IndexedDb, both have limitation in storage size. The official document says, Safari browser allocates max of 50 MB and Chrome mobile allocates 6% of free disk space for local storage.
Is there any option to store the images and videos of large size locally and display the same in PWA app when the device is in offline?
You can't bypass the storage constraints set by the browsers(different for each browser as you have observed). Most of the browsers will let you store more(with users permissions where applicable) but that has to be noted is, these data can also be deleted by the browser without your application having any control over preventing it.
Its a snadboxed storage your browser allocated to your app and it can always take back on different scenarios.. like when the disk space goes low, user clears cache etc.,
You can rely on it as long as you have a fallback when the file is cleared. If you are thinking of storing GBs of data, this option is not for you. But if it goes couple of hundred MBs, you should be okay with most browsers, provided user accepts to allocate the space.

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

App storage allocation and low storage notification

I'm working on a project that stores many images when the app is running.
Say for instance an app when installed uses about 30 megabytes of device storage, but after it launches and during operating, it requires 90 megabytes additional storage to operate properly.
Does iOS allocate and limit storage for apps when they run?
Does iOS notify apps when storage is low or completely used, and if so in what way?
Does iOS allocate and limit storage for apps when they run?
iOS does not limit storage. If a device runs out of it, you'll get write fails.
Does iOS notify apps when storage is low or completely used, and if so in what way?
There is no such notification to subscribe for. I suggest you just to check the free space left periodically and swiftly handle write errors.
As for you case you could allocate some kind of a scratch file for "reserving" the capacity you need, but this is not a friendly approach.
You could also notify the user that x MBs of space is left and app will stop working if it's gone under y MBs of space.

Is it possible to track the data collected by iPhone apps in your device with relevant server names they are sent to?

I want to develop an iPhone application which can track the contents (such as location information, device hardware/sw information, contacts …etc) being collected from your device by all the applications and give a report to the end user at end of each week.
Because, I believe that end user should be notified about what information being collected by his device and sent to which servers to store them.
I Googled it and read few articles as well, but all pointed to the conclusion that a given application cannot (or restricted by Apple) peak into operations of other apps and collect any information about what those applications are doing.
But I've seen this Onovo Count app http://www.onavo.com/apps/iphone_count is collecting the data usage of all the other apps in your device, so can we just go few steps beyond that get this done ?
From the looks of it Onovo Count redirects all device traffic through a VPN. I presume their servers look at the host names of the traffic and record it against the device. When looking at the app, you're just looking at a dump of the data for your device.
For the rest of what you want to do, it is not possible on a standard device, you'd need to have it jail broken or something.

iOS Any Size Limits for Local Storage

We are developing an in-house app which will have access to a large amount of image data which we would prefer to be off-line.
In short at first start-up the app will pull down the data from a server (around 3Gb) and then only get the data again when the user asks for an update. I simply want to know if there are any size limits for persistent local storage?
Again note this is an in-house app for around 100 users and they are near servers with WiFi, all devices are iOS6, retina (new basically). The updates will only be a few times a year and we may even code it so only changes are downloaded.
There are no limits to the amount of data your app can store. We have apps pulling down over 10GB of data with no trouble.
The only thing you need to be careful of is storing the data in the Caches directory (or setting the 'do not backup' flag) to avoid it being backed up to iCloud if the user has that configured on their device.

Resources