Storing data are no sensitive in the application forever - ios

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

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.

How to persist core data in cloud without authentication

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

What's the difference between Keychain and App group in iOS

As you know that when we share data between two apps in iOS, we can use keychain. And iOS8 later, we can also use app groups to implement the same function;
My question is what's the difference between keychain and app groups, which one will be better and why ?
Keychain
If we save the data in the keychain, it still remains there when you uninstall the app unless it is completely reset.
For example, you might implement some login functionality and save it in the keychain. If the user uninstalls the app later then re-installs the app, you can grab those values from the keychain.
App groups
App groups are mainly used when you want to share data (for example SQLite or Core Data) between your apps.
For example, if your app has a widget and it wants to get data from SQLite or Core Data, then you would create an app group and save the SQLite or Core Data file in that app group path instead of the app's document directory. Now both your widget and app can track the changes in your DB file.
These are some common examples of the things you asked.

How to keep my apps data undelete even if my app is removed?

My app is a Gov app where a user captures photo and record some notes about it.
When the user removed the app, all data are lost.
Is there a place where I can store data (notes & photos) for the user even if they removed my app, then installed it again, it will be still there?
Note: This can be done easily with Android, by using a public directory.
Use server to save large files.
and keep user token in keychain. The data in keychain will NOT be deleted when app was deleted.
when user reinstall your app, you can get this token, and use it to download large files.
iCloud is other space to save your data.

Storing usernames and password

right now I'm using Core Data - sqlite for database. And I have a few questions related to it.
I created a Modal with all the personal information of the user: username, date of birth, address, zip, state, etc... The password I'm using Keychain for login functionality. So, my basic question is:
Where is this information stored? Locally in the user's iphone? But what if I have millions of users, wouldn't that database file be too big? Is it safe? I mean, users can see information of another users?
How can I edit that database if not programatically in xcode? I mean, what if I want to delete some user or change some specific information.
Thanks.
Creating a local sqlite database on the device will only store the individual users info as each app is obviously stored on each device separately. Users won't see each others info.
You will need to edit data in the database programatically via the app (ie code written in xcode)
Keychain data will be stored inside a local db in the device. This is a shared db for several apps. So after you delete and reinstall the app, you will get the data. Million users may have their own devices. not logging in from a single device. The data in this keychain will be stored in the encrypted format. So you dont need to worry about the security.
In iPhone simulator, the data will be stored in ~/Library/Application Support/iPhone Simulator/<Version Number>/Library/Keychains/
If you want to edit or delete the item, then try the below tutorial
http://useyourloaf.com/blog/2010/03/29/simple-iphone-keychain-access.html
if you use Core Data - sqlite for database then every user(device) has their own copy of databse.
so don't worry about file size & information of other users.
And you can edit that databse only by your app or by app's background Process in case of Core Data

Resources