import/export files from/to iCloud from our application - ios

I am working on iCloud api's for the first time. I want to import/export files (.doc,.pdf,.xls any kind of file) from/to iCloud through our application.
In our application there will be different kind of documents which the user should be able to save in cloud and, when user is using same application from different devices, all files which are saved in iCloud should fetch & show.

Related

Storing a text file in iCloud in Xamarin

I need some clarification and Microsoft documentation is only confusing me more.
I want to save a txt file in iCloud so the user doesn't loose some data that belongs to them.
This db document is some information I am retrieving from a local database and storing in a text file. I have seen two ways of doing this.. however all the posts on this topic are very outdated and I don't know which way might be best or if they are even doing what I trying to do.
All I would like is to be able to have the user backup this particular file to their iCloud account, so they can still keep this info even if they change phones or delete the app and want to restore from iCloud.
Microsoft's documentation points me to this page https://learn.microsoft.com/en-us/xamarin/ios/data-cloud/introduction-to-icloud
I began setting up the provisioning profiles and setting the iCloud options on the entitlements page etc. However the documentation when sideways for me when they began creating a monkey page UI Document and having the user manager the ubiquity documents (which I don't want) I actually don't want the user even seeing this Txt file. However this option shows how to check if the iCloud is even turned on on this user's phone.
Now this other option I think is more straight forward and I read the documentation on it here https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/file-system using something like this to store and retrieve a document:
var libraryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "..", "Library");
However what if iCloud is turned off? Is this an automatic backup option?
Any type of explanation is helpful.
The iCloud storage API in iOS 5 allows applications to save user documents and application-specific data to a central location and access those items from all the user's devices.
About the definition of iCloud, you will know that it will save your data to cloud server. And it can be used in all the user's device if turn on the iCloud.
However what if iCloud is turned off?Is this an automatic backup option?
Therefore, if iCloud is turned off, you could backup the data in device although it will not be used for other user's devices. You could save it in Application directories. This should be a good chooice to backup your data. And you also can get the data when you need them.
In addition, you also can use other cloud server APIs to backup your data. Such as Azure Storage, Firebase Storage etc.

How to access all the iCloud drive files (outside app container) without UIDocumentPickerViewController?

I need to make an app that fetches data from iCloud Drive (outside app container, all the user files stored in the iCloud) and shows it in UICollectionView. Is it possible without UIDocumentPickerViewController?
You can do the same using the iCloud integration. with iCloud integration you can upload and get the data from iCloud here are some reference tutorial to kickstart.
https://www.raywenderlich.com/1000-cloudkit-tutorial-getting-started
https://iosdevcenters.blogspot.com/2017/03/icloud-integration-in-swift-30.html

Export & Import Documents using iCloud in IOS

I am developing an app that makes user to export core data records into an document using iCloud Drive/iCloud Documents/iCloud Kit and he can able to import and access those document at another device.
I mean Export/Import of documents within devices that are using same application. Documents can be identified by unique document name for importing..
Please Give any suggestions for above task. Which one is more useful..or suggest any other useful links for above task.
1) iCloud Documents. (Documents Storage)
2) iCloud Kit.(Huge/complex amount of data)
3) Key-Value Storage.(Small amount of data)
I have successfully implemented export/import using iCloud Documents. But I am able to access the documents which are exported in same device only. As it stores with local storage..
I used iCloudSync for retrieving the documents.
https://github.com/iRareMedia/iCloudDocumentSync
Now, I am referring iCloud Kit for accessing within same app & multiple devices..
Thanks..!
I have successfully accessed the iCloud Files with same iCloud Account within multiple devices using below code
NSArray *tempArray=[[iCloud sharedCloud] listCloudFiles];
Source: https://github.com/iRareMedia/iCloudDocumentSync
It will retrieve all the iCloud files of same logged in iCloud Account that are exported from various devices..

iCloud sync files and core data

In my app I save images in file manager and their metadata(image name,created date,notes and image path) in core data.
I want to know the best practice to sync these data using iCloud.
If you save the images in the ubiquity container they will be synchronised across devices. However you may need to store a relative pathname rather than an absolute pathname.
If you take a look at the the sample apps at the link below you will find the app uses iCloud to synchronise the Core Data database using transaction logs and it uses iCloud to synchronise the backup files the user makes. So while this is not exactly what you want it would be pretty easy to modify the code for saving the backup files to iCloud to save your files to iCloud.
You do need to remember that iOS will not automatically download files from iCloud so you would have to do that from your App prior to trying to use them on the device.
http://ossh.com.au/design-and-technology/software-development/

Can my app let users save some files to iCloud and rest on device

In Apple's Document Based App Development Guide, it emphasizes that our app should let users choose either to save all their files to iCloud or save all on local device. Is there reason for this? Can we actually allow users to pick some files to be saved on iCloud and some to be saved locally, like the TextEdit app on mac OS X? Will App Store disapprove iOS apps configured in this way if it is programmatically possible?
Thanks!
Here is a link
https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/DocumentBasedAppPGiOS/ManageDocumentLifeCycle/ManageDocumentLifeCycle.html#//apple_ref/doc/uid/TP40011149-CH4-SW1
Setting the Preferred Storage Location for Document Files
All documents of an application are stored either in the local sandbox or in an iCloud container directory. A user should not be able to select individual documents for storage in iCloud.
When an application launches for the first time on a device, it should do the following:
If iCloud is not configured, ask users if they want to configure it (and, preferably, transfer them to Launch Settings if they want to configure iCloud).
If iCloud is configured but not enabled for the application, ask users if they want to enable iCloud—in other words, ask if they want all of their documents saved to iCloud. Store the response as a user preference.
Based on this preference, an application writes document files either to the local application sandbox or the iCloud container directory. (For details, see “Moving Documents to and from iCloud Storage.”) An application should expose a switch in the Settings application that enables users to move documents between local storage and iCloud storage.
If it makes sense for your app, there is no reason Apple would care if you save some files locally and some in iCloud. It's not a hard fast rule to be all one way or the other.

Resources