iCloud Integration for uploading and downloading files - ios

I want to design an app which stores documents on iCloud. But there are some question which has answer before doing actual implementation.
The question are as follows,
What is maximum file size to upload on iCloud?
Can I programmatically calculate/know the available space on user's
iCloud account?
How can I get the event for uploading and Downloading files from
iCloud?
Can anyone please help me here ? I read the apple documentation but not understood all the things completely.
Thanks In Advance.

Although you mentioned you've read the apple icloud documentation, the designing for icloud documentation page from Apple is still a good starting point for this question.
File Size Limits
The documentation doesn't specify a Document file size limit, nor a Core Data storage limit, other than a user account icloud storage allowance. There is a limit for Key Value storage which is 1Mb for a value (in a value-key pair), which could be an issue for you, but otherwise it seems you can store large files as long as the user has enough space available.
Given the 5gb default amount and accounting for the default user storage needs (photos, contacts, calendars and the like), you may encounter limits for Document and Core Data storage, like any other app. The file management for icloud page mentions good app behaviour:
Apps that take advantage of iCloud storage features should act
responsibly when storing data in there. The space available in each
user’s account is limited and is shared by all apps. In addition,
users can see how much space is consumed by a given app and choose to
delete documents and data associated with your app. For these reasons,
it is in your app’s interest to be responsible about what files you
store.
Check Available Space Programmatically
No
Upload/Download Events
The file uploading and downloading is handled by the OS. All files are stored locally, it's from this local store that you request/modify/save documents. From the icloud fundamentals page:
When you adopt iCloud, the operating system initiates and manages
uploading and downloading of data for the devices attached to an
iCloud account. Your app does not directly communicate with iCloud
servers and, in most cases, does not invoke upload or download of
data.
See this app coda tutorial for an example of key-value store integration, this Tim Roadley tutorial for Core Data store integration or this Ray Wenderlich tutorial for Document store integration.
Edit: The Document-Based App Programming Guide for iOS provides code snippets for moving files to/from iCloud, uploading and downloading as well as monitoring file changes. See "Downloading Document Files from iCloud" and "Moving a Document to iCloud Storage".

Related

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.

Core Data - Savings and sharing images via iCloud

I have an app that allows a user to either take photo or point to a photo on from their camera roll. This record must be peristed locally. A record consists of text and an image. Savings this data on a single device seems simple, as I can persist the link to the image or store the image locally in the file system if taken via camera.
Problem is how to share this record via iCloud to make record available to all instances of the app on multiple devices. I.e iPhone creates a record with an image, which is then available to view on iPad or Apple TV.
Is it efficient to store a UIImage in a Core Data record and make this available via iCloud? Many people saying not for local storage
My concern is this could potentially be some large quantities of data?
Does anyone have any thoughts on how to solve this issue?
I´m working on a similar app, for me working with http://Parse.com is a solution.
If your user have an internet connection and can wait to upload the images/text files you can save it directly using Parse (with a fancy progress Bar!) But if you want to make it network-less proof, you might work as whatsapp. I mean using Core Data to save your files locally, then try to upload the imagens whenever there is internet available.
There are some others clouds DB you can use, but I´m familiar with this one.
You can upload to iCloud using NSFileManager.
There is a complete walkthrough on how to do that.

iCloud Drive vs. iCloud Documents

I am a bit confused. I am using iCloud Drive to store backups from my internal data each time the user clicks 'backup'. This doesn't work as I would like to, because sometimes it just doesn't sync between the devices and users that click restore get's their old backup.
Now I've read about iCloud Documents and that you could trigger a sync manually from there. What's the difference between iCloud Drive and iCloud Documents for me as a developer? I just don't get it..
I am not sure whether it would be better to store backups with iCloud Documents...?
I think iCloud Drive provides the service that user can edit document through specified interface.
In contrast, iCloud Documents Storage provides a kind of service that stores some confidential or unchangeable data for application.
iCloud Drive - Apple's Cloud-Based Service for consumers. Typical known for their ability to sync between different devices through storage in the Cloud.
iCloud Document - A single file of UIDocument type.
iCloud document storage - Service that provides developer access to iCloud for their files which are usually UIDocument type or file packages which are of NSFileWrapper.
iCloud - Cumulative set of Apple's cloud services consisting of iCloud document storage, Key-value storage, CloudKit, Core Data.
So above question is not relevant as they are not comparable technology.

Does iOS' 8 iCloud Drive enable different users to share files?

C.f. Apple website page on iCloud Drive:
http://www.apple.com/ios/ios8/icloud-drive/
I understand iCloud Drive makes easy for an individual user to save a file to the cloud and work on it from any of his or her own devices, i.e. a solo use case.
My question is: with the new iCloud Drive, can different users, with different Apple accounts (not necessarily in the same family), share and collaborate on files? E.g. Could an iOS 8 app help a bunch of users collaborate on, say, a video editing project where all the heavy raw footage video files are shared on iCloud Drive?
CloudKit is for backend app usage for developers. It has nothing to do with iCloud Drive user accounts. Time will tell how sharing works with iCloud Drive.
Answering my own question: yes, it is possible thanks to CloudKit, c.f.
https://developer.apple.com/icloud/documentation/cloudkit-storage/

Storage for iOS development

I have db which is kept in Core Data and I need to download full data from some storage. I don't want to write web server for this. Is there any way to store my full data for further downloading? Can I use iCloud for this? Or anything else? Thank you
iCloud is connected to you personal Apple ID, so it would not be possible (or at least not its intended use) to allow others to download data from your iCloud account.
Have a look at Parse or Azure. One of them might be the solution you are looking for.

Resources