Learn Courses My Dashboard

Core Data + Cloudkit

Hi everyone!

I would like to make an app what uses a database, but I’m not sure if Core Data + Cloudkit is good for this application or I should choose an other solution like Firebase. I would like to implement the following features:

  1. User account registration or login with email
  2. User can add data what is saved to the local device (using core data)
  3. Save/Sync the new data to the online database also (backup)
  4. Need to get the data when device is offline (that is why I surely need core data)
  5. Database synchronization between devices (sync the data from the database when the app starts on the other device)

So I need a central database where I can store the user’s data.

Can I do this with Core Data + Cloudkit? Or it can save to only the user’s iCloud storage and nobody can reach the database except from the iCloud storage owner?

I hope you understand what I need :slight_smile:

Thank you

Yes you can use CoreData+CloudKit for this scenario, and it will save to the user’s iCloud account. Only the user has access to the data, you as a developer do not.

You don’t need to have any kind of account registration when using CoreData+CloudKit, “it just works” automatically with the user’s Apple account

You can also accomplish the same with Firebase, but CloudKit+CoreData work too. It’s up to you which you want to use in this scenario

Thanks for reply!

In this case I think firebase is the better solution, since me as the developer can store the data so the users have “backup” what can’t be deleted by them. And in the future if I want to develop webapp or android app I can not be able to migrate their data.

For offline data I need to use core data, Am I right?

And what is your opinion about to use core data + cloudkit + firebase? Or is it too much effort for “nothing”?

1 Like

How experienced are you?? If this is your first big project I would NOT try to sync all 3.

Pick Firebase or pick CloudKit

You don’t have to! Search Firebase offline support! I haven’t done too much with this, so I’m not sure it’s limitations, but it could work! Otherwise you can use core data :+1:

I agree with @mikaelacaron. If you’re new, you should focus first on learning what you can.

If you’re going to use Cloud Firestore (from Firebase), you no longer need to use Core Data. Firestore does have local storage for offline data, and it syncs the data (in real-time) when the user goes back online, with minimal effort on your side.

Core Data + CloudKit + Cloud Firestore (from Firebase) would be redundant, but if you’re using Core Data (offline data) + Cloudkit (as your backend database), you can still use other services from Firebase such as Crashlytics (crash monitoring), Google Analytics (for user analytics), Authentication (for email login or other social app authentication), Cloud messaging (for push notifications), and Dynamic Links (for deep linking).

If you’re going to the Core Data + CloudKit route, you need to be aware of how to design your app for data access. You may refer to this document for the design guide:

Designing with CloudKit - iCloud - Apple Developer

Though you are probably right that there is no direct access to CloudKit for the Android platform. CloudKit has an interface for the web with CloudKit js. You will still probably need to write a backend service with node if you’re going this route. Your Android app will have to communicate with the node backend via an API, but this is just an opinion, and I’m not really sure if it is in fact feasible.

If you’re going to use this in production (as you’re planning for the future), you also need to be wary of the cost. The cost of using cloud services tend to scale with your usage, and each platform has their own usage pricing.

Yes, it will be my first bigger project, I’ve just started to design the database structure. This app is something like a wallet app where you can write in your spending, track them with “fancy” diagrams and some other feature.

I prefer the apple ecosystem, that is why I want to use core data, but I would like email registration like almost all similar app does.

I don’t want to create/maintain my own server/database, but I’m not sure which solution fits the best and the most common for these problems.

But now I guess firebase + core data would be the best, since cloudkit doesn’t have the opportunity to register with email function, it will always use the users’ apple ID and I’m not able to access their data in their database.

If I’m correct if I use cloudkit I will lose the opportunity of the email registration, since it always use the apple ID of the user so do not need the registration form and login form, everything happens in the background.

I will check the offline data of Firestore, but I prefer core data, since it is apple’s own framework.

I really want email registration and I want to store the users data so it seems cloudkit is not an option anymore.

It will be my first bigger app so I’m not sure I’m thinking right, but almost every app has a registration/login form when you start it. And I also think it is better to store data in a central database where the developer can access them. By the way what is the privacy policy in this case? I guess I have to encrypt the users’ data or is it enough if only the user can access his data after successful login?

All in all, I just want to use the most common solution in the market :slight_smile:

I would highly recommend CloudKit and CoreData

It’s NOT a bad thing to not have email sign in! That’s a whole extra step! Witt CloudKit it automatically uses the user’s iCloud account so they can immediately just start using the app. (Which is a good thing!!) it annoys me so much when the first thing you see with an app is a login screen, cause idk if I even like the app and I already need to make an account.

Also apple’s guidelines want you to delay sign in as long as possible on their apps.

You can still use the user’s data from CloudKit!! But you just can’t see it! As in you set up the structure for how it’s saved and how to use the data, but you just don’t get to see exactly what the user saved. For privacy reasons and it’s already secure so it’s super easy.

—-

From everything you’ve said, you should use CoreData and CloudKit

Ok, I beleive you. I just always see every similar app start with sign in form. But yes, sometimes it is annoying when you just want to test an app.

What is still not clear for me that the data will be stored in my (developer/app’s account) iCloud or the user’s iCloud? If it will be stored in the user’s iCloud then what is this pricing stuff? In case of firestore it is clear, I have a database and users can access and use my storage to store data. Or is it the same with cloudkit just do not need to register since the user automatically log in with his/her apple iCloud account?

The data will be stored in the user’s iCloud account!

CloudKit is set up that it’s pretty much free, with limits. Meaning you can store a bunch of stuff (depending on the user’s limits) BUT Apple doesn’t want you to abuse CloudKit

This is a great overview video on how pricing works, which is also part of Sean Allen’s course on how to use CloudKit and MapKit