iCloud sync files and core data - ios

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/

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.

iOS App Submission Rejection

When i submit my iOS app i got following rejection issues from apple.
On launch and content download, your app stores 13.14MB on the user's iCloud, which does not comply with the iOS Data Storage Guidelines.
Next Steps
Please verify that only the content that the user creates using your app, e.g., documents, new files, edits, etc. is backed up by iCloud as required by the iOS Data Storage Guidelines. Also, check that any temporary files used by your app are only stored in the /tmp directory; please remember to remove or delete the files stored in this location when it is determined they are no longer needed.
Data that can be recreated but must persist for proper functioning of your app - or because users expect it to be available for offline use - should be marked with the "do not back up" attribute. For NSURL objects, add the NSURLIsExcludedFromBackupKey attribute to prevent the corresponding file from being backed up. For CFURLRef objects, use the corresponding kCRUFLIsExcludedFromBackupKey attribute.
Your App stores data in the users iCloud. This is only alowed to a certain degree.
The 13,14 MB your app stores to the cloud is just too much.
I never submitted an app to Apple, but the error message is clear and defined.
Take a look on your app and what it does store in the iCloud. Reduce the size or just dont write to iCloud.
Hope it helps...
*edit
Why would one write to the iCloud anyways? Just write on the phone memory.
Do you call a web service on App launch which stores data in the App's documents directory? Or do you store some other data in the App's documents directory?
By default all the data in the App's documents directory is synced to iCloud. So any data that can be recreated later (unlike session data) must not be stored on the documents directory.
So instead save data in the App's Temp directory.
To do that have a look at this- How to save images and recoded files in temp directory?
Another option is you have is How to use addSkipBackupAttributeToItemAtURL API?

How to save my data in iOS document folder?

My application need to save data to my local database. The reason why I want to save it to document folder is I want the data shared by all devices with the same iCloud account. What I normally do is to copy the empty database from my Bundle into my document folder the first time when the app launch. But I'm not very sure it will be rejected by Apple or not? (Because one of my app which preloading a database into document folder was rejected.) Do you have better strategy? (I know I can save the data into library folder. But the data will not be synchronized then.)
Thanks.

iCloud setting like clear app in ios

I have tried many iCloud example but I want to migrate iCloud to local and local to iCloud without duplication like in Clear app in ios. I have tried this example too
iCloudStoreManager
Can You please help me to solve it.
You can try the following:
If the user wants to keep the cloud data, delete the local store before creating the persistent store with iCloud settings turned on. iCloud should then populate your local store with the data from the cloud automatically.
If the user wants to keep the local data, migrate the existing local store to a new temporary store with no iCloud settings, then use the NSPersistentStoreCoordinator method
+removeUbiquitousContentAndPersistentStoreAtURL:error: to remove the existing iCloud data. Finally, migrate the temporary store back with iCloud settings turned on. You should end up with only the data from the temporary store.
Another option is to not remove any data at all, but deduplicate data as mentioned by Tom Harrington.
Lastly, you might have more luck with the Ensembles open source framework. It works with iCloud, but — being an open source project — is more transparent than Apple's solution, and generally easier to get up and running. (Disclosure: I am a developer of Ensembles)

import/export files from/to iCloud from our application

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.

Resources