How to persist core data in cloud without authentication - ios

I am designing an app using core data which has a local Cache. I am thinking of using CloudKit for syncing it across multiple iOS devices. Since CloudKit is not for persisting data, I am pretty sure that if user loses their phone that data is gone forever. My app doesn't require any authentication so how do I save the data in cloud along with local Cache so that it can be sync across multiple iOS devices like iPad or iWatch
P.S. Is it possible to save user generated content files in Documents so that they can get backed up by iCloud automatically without using CloudKit?

The data is backed up on iTunes and iCloud periodically, so if your user changes the device then they can restore the data from there.Yes it is possible to save user generated content files in Documents so that they can get backed up by iCloud automatically without using CloudKit

As per your problem , Only creating Coredata enables you to manage data across different devices but two important question need to understand before this :
How can you preload existing data into the SQLite database?
How can you use an existing SQLite database in Xcode project?
Here is one of hot favourite tutorial for managing this :
https://www.raywenderlich.com/27657/how-to-perform-a-lightweight-core-data-migration

Related

Share database [core data] between different devices, not just the user's ones

What is the best way, to share a database between different devices, that are not just the user’s ones, but for example could be his friend’s phone. That means that iCloud is not an option.
Example:
 All of my data is app-user specific, so basically:
user logs into my app, do some work
then he can log in with the same acc on his friend phone and data should be the same
Is there an any way to upload the whole user specific database to some online storage provider (like firebase,… ) and then download it on another device and initialise core data stack, when the same user logs in on a different device?
Or is it the only way to sync data with the server and than preload the database?
You could simply upload the whole database file(s) and then download it on another device. The problem though is portability. You need to ensure that both devices support the same version of the database so they are compatible. To port the same thing to another platform is again a different story but doable when not using core data.
Then there is a problem of conflicts. Imagine you forget to log out from the second device and you open it after a week and the database is accidentally synced back to the server. This will make you lose all the data you created on your "main" device.
So in general it is possible to sync the whole thing but you will have loads of issues. You should create a server that supports all entities and works through ids (so you know the object was modified and not created) and date modified to be able to resolve conflicts.
Syncing data between multiple devices is the biggest reason to use something like Firebase. That's one of its primary purposes. You would use Firebase for data storage instead of Core Data, and it would automatically handle syncing between devices. You don't write code to upload or download anything, you just read and write Firebase data and it handles the syncing. It supports user accounts, so if a user logs on on a different device, their data automatically syncs to that device. There are numerous other options besides Firebase, of course.
CloudKit also syncs between different devices, but it's linked to the current iCloud account on the phone. Since you want in-app login, it's not so good.

syncing CloudKit and iCloud

I have an app which currently syncs via iCloud, so the user can use the app on multiple iOS devices and has the same data everywhere.
Now I'd like to switch to CloudKit; but how is this possible if the user e.g. only updates on one device? So it's the same user, one time with CloudKit, one time still with iCloud... I guess syncing isn't possible then if I get it right?
just check if there is data in the private container. If not, then migrate and sync the data from iCloud to CloudKit. Then if he opens the app on another device then the data is already migrated to CloudKit and you can just sync that data.

How to persist data in Core Data through delete and reinstall of the App

I have an iOS app that uses Core Data. I would like to make sure that the data does not get lost if the user deletes and re-installs the app. I was wondering if using iCloud with Core Data is the solution to what I wish to achieve?
Correct. Using iCloud should preserve the data and reload it upon fresh installation.

Storing data are no sensitive in the application forever

I want to save no sensitive data in my app,
The data not delete when the app delete.
I saved in keychain but I see that In keychain save only sensitive data.
where I can to save my data?
There is no such place on iOS where you can save data that stays on the device even if your app is deleted, except for the keychain...
This is because your app is running in a Sandbox that holds all the data that belongs to your app. You have a few possibilities to achieve persistence within the context of your app (e.g. using the Documents directory of your app, NSUserDefaults or Core Data,...), but for any of these, there is the restriction that the data gets deleted along with the app.
The other option is to store the data in the cloud, either writing your own server side system to store the information or using a service like Parse.com

Is Data stored using store.js persisted to the phone? Can up back it up to the cloud?

I have an iOS PhoneGap app. I'm storing some values using store.js. This works great. I'm a little confused about where this data goes. Is it stored to the apps data? So clearing the app's data from settings would remove it? Or is it stored with safari data? If I back up my apps data using cloud back up, will it be retrieved if I restore the phone?
Probably your data was stored at Web Storage. Try this Storing Objects in HTML5 localStorage issue.
Your data is stored in the application sandbox and is not persisted to iCloud.
You need to write a phonegap plugin to handle persistence to iCloud, or send some ajax calls and do the persistence yourself.
I was trying to look around for an iCloud Phonegap plugin but have not found one yet.

Resources