Nick! You don't know how much I've been looking for a complete CloudKit tutorial :O... This will save my ass soooo much! Keep up this awesome series and I hope you can cover all CloudKit functionalities as much as you can because I was really looking forward to see the power that CloudKit can give. Thank you again!
Hey MKE! Well I have 5 CloudKit videos so far, it's not a "complete" tutorial but should cover most use cases (enough to build most apps at least). At the end, if there's anything major I missed, definitely leave a comment letting me know 🤙
Hi! Thank you for making this video! It's so helpful for learning how to develope the iCloudKit. BTW, I have one question: at 14:29 in this video, how did you make that func to choose and make a Vstack? Thanks,
Great job as usual, Nick! You have a genuine knack for hitting the things that matter. Question of the sequence of events ... first you call getiCloudStatus, which does an CKContainer api (I assume this is asynced, right?), immediately you call requestPermission. Could the CKContainer api not yet be complete when you call requestPermission, or is the getiCloudStatus always going to be done executing before requestPermission is called? I don't quite understand - does the requestPermission func need isSignedInToiCloud to be true for the func to give the correct result, or does it not matter whether the user is signed in for requestPermission to work? Thanks for your help!
Great question as always! This is all async code, so yes timing definitely matters here. The app is automatically connected to the CKContainer and CloudKit, so we don't have to worry about that here. We do, however, need the user to be signed in to their iCloud account before they can access CloudKit. So the first function to call is getiCloudStatus() and then after that you can call requestPermission(). Almost all of the time, getiCloudStatus() will immediately return successful though. I don't know anyone using an iPhone that isn't signed in to an iCloud account. In production, I would probably call these one-after-another just in case. If the user getiCloudStatus() does fail, though, I would probably stop everything else in the app and show a screen saying "sign in to iCloud to continue" or something like that. Also, in reality, the getiCloudStatus() can be called at app launch in the AppDelegate or something like that, while requestPermission() might called much later in the lifecycle, such as during onboarding or after creating an account.
Great video, thanks for creating content around CloudKit. Been a big fan of CK since the beginning but there has always been a lack of good documentation and learning resources on the topic.
on 22:42 is there any way to fetch the actual name of the user, for example if the iCloudAccountStatus is .available, to show something like "Hello Nick Sarno !" ? (Edited 10 seconds later: OK got it !!)
Hi, much thanks for your courses, I learned a lot really. Now, I can use CKContainer to CRUD public database of my container, which I can call it as "online mode" of my APP. But, if there is a "offline mode" of my APP, I use Core Data to read and write, how can these operations synchronze to the public database? Since I know, the NSPersistentCloudKitContainer support privdate database well and thought supports public database but now very well. I think in the offline mode of my APP, to enable data synchronization to public database when network is available, I have to continue to use Core Data and use CKContainer to manually upload loal changes to public database. Am I right?
this is the problem with the content creators... they don't care to update the videos... so useless and waste so much time... i know it is free but make us aware that many of the functions are depricated for god's sake
Hi Nick, Fantastic tutorial as always. I found one small issue that tripped me up several times when I tried to request application permissions using async await, and I thought I'd add it here in case others who follow your series hit the same snag. I kept getting a notice in the console: [CK] Could not validate account info cache. (This is a potential performance issue.). When I requested permission in the app, the oddly-worded dialog you mention at 30:10 came up, but when I clicked 'Allow', it fails to return a CKPermissionStatus. The fix is perhaps obvious to most, but took me most of a day to figure out: you have to go to the CloudKit Console. . . Indexes and create an index for the Users. The 'validate info cache' message goes away, and the permission status is set to granted. Keep up the great work!
A quick follow up: if I failed to index the Users before I requested permission, I could not reset the simulator to re-ask for permission (for example, no luck when trying to Reset Environment from the CloudKit Console, or even creating a new CloudKit database and indexing the Users). The only solution that I could find was to create an entirely new project, add the CloudKit capability, index the Users, and then request permission.
Hi Nick. Quick question. Despite requesting permission, the returnedStatus is always could not complete. Did you have any experience with this, or any tips to fix this issue?
Hello Nick, as always, you are super... May I ask one question: I am based in the EU, and according to the DGPR law, how does CloudKit work under the hood? Is cloud kit safe for hack attacks or similar? Thanks for your attention
Hey Romesh! CloudKit is provided and maintained by Apple, so I'm sure it is very safe to use. Here is a quick link with some info: support.apple.com/guide/security/cloudkit-security-sec3d52c0374/web
In the case where the user has temporarily no access to the internet, is Cloudkit smart enough to store new records created by the app locally then fire the records out to the cloud when the connection is re-established, or is the app dead while disconnected? Thanks!
Hey Craig! Hope all is well with you.... No, CloudKit isn't that smart. I believe we can integrate it with CoreData to do this but honestly, I'm not familiar enough to say for sure. Regardless of using CloudKit, many apps will implement a fall back to temporarily save data in UserDefaults or CoreData while the user is offline.
The reason you cannot delete a cloudkit container is because Apple protects user data at all costs. The data in the apps CloudKit container belongs to the user not the app. To most it seems reasonable that before release there shouldn’t be any user data but Apple isn’t going to take on that burden when it comes to beta testers and sorting it out.
I am getting signed in = true, but permission: False; no chance to give permission . Maybe there is a simulator setting i haven't set ?? thanks for help
OK, fixed it ! I didn't realize that (apparently) the iCloud container's name must be identical to the bundle identifier. At least making this change worked for me !
@@thejaplong They don't have to be but it makes it a lot easier to setup if they are, since I believe if you want a different bundle identifier you have to manually initialise CKContainer whatever it is with that bundle identifier.
I get the same problem, I can’t get the permission window to come on the screen, I read that a lot of people are having the same issue, I tried resetting the environment in CloudKit but it still will not show the permission popup… my identifier and container are the same name… I will look into manually initializing the container as George mentioned… but I don’t know how to do that…
@@dennismallette258 just add a let container = CKContainer(identifier: "YOURCONTAINERID") and then use in requestPermission() container.requestApplicationPermsission... instead of CKContainer.default()
Hi! I got the permission pop up when i following to your video, but when i came to my little demo , with using same code and same Cloud Containter or new, I didn`t get the pop up ...😢😢😢 , and I found that the returnedStatus in requestPermission is returning [.couldNotComplete] instead of [.granted]
Nick are you willing to do a video on sharing my privateCloudDatabase with another user? I have a clinic database for iPad & iPhone and I can use it but my wife can’t unless she logs out then logs in as me! I have spent weeks trying to learn how to do this, yet Apple documentation is most difficult as to be useless!
Hey Craig, I honestly don’t know enough about this to do an in-depth video any time soon. I know it is definitely possible without having to sign into each other’s accounts. There should be some documentation online around CKShare, but I think you need to set up Zones first - which is a whole topic in itself. I did a poll recently on topics to cover and there wasn’t much interest in CloudKit, so I’m not sure when I’ll get to this. On the brightside, Firebase ranked pretty high, which I know I promised you a while ago 😭😅
I was able to login to my iCloud account on the device simulator, but the status and permissions both say false. Not sure if this is the problem or not, but my Xcode account is different from my iCloud account with different logins.
@@SwiftfulThinking I am pretty sure it is setup properly as I can save items to the cloud and display them in a list. Not sure what I might be missing.
The call to requestApplicationPermission fails for me. I get CKApplicationPermissionStatus(rawValue: 1) and the error messages "Service Unavailable", "Request failed with http status code 503".