cloudkit

CKFetchNotificationChangesOperation returning old notifications

吃可爱长大的小学妹 提交于 2019-11-30 22:21:12
I'm working on a CloudKit-based app that uses CKSubscription notifications to keep track of changes to a public database. Whenever the app receives a push notification I check the notification queue with CKFetchNotificationChangesOperation and mark each notification read after processing it: __block NSMutableArray *notificationIds = [NSMutableArray new]; CKFetchNotificationChangesOperation *operation = [[CKFetchNotificationChangesOperation alloc] initWithPreviousServerChangeToken:self.serverChangeToken]; operation.notificationChangedBlock = ^(CKNotification *notification) { [notificationIds

Can you share data on CloudKit between different apps

时光总嘲笑我的痴心妄想 提交于 2019-11-30 18:44:33
I have a free and paid version of my app in the app store. I'm updating the app to share some public data using CloudKit. I'd like both the free and paid apps to share the same data. Firstly is it possible for two apps to share the same data with CloudKit? If so, how can I get this to work? I've tried enabling CloudKit in the capabilities of both targets and selecting the same container in both apps. The main app which has 'Use default container' selected works fine, but the other app, on which I've selected 'Specify custom containers' and selected the custom container from the first target,

CKFetchNotificationChangesOperation returning old notifications

*爱你&永不变心* 提交于 2019-11-30 18:15:30
问题 I'm working on a CloudKit-based app that uses CKSubscription notifications to keep track of changes to a public database. Whenever the app receives a push notification I check the notification queue with CKFetchNotificationChangesOperation and mark each notification read after processing it: __block NSMutableArray *notificationIds = [NSMutableArray new]; CKFetchNotificationChangesOperation *operation = [[CKFetchNotificationChangesOperation alloc] initWithPreviousServerChangeToken:self

Can you share data on CloudKit between different apps

不羁岁月 提交于 2019-11-30 16:54:24
问题 I have a free and paid version of my app in the app store. I'm updating the app to share some public data using CloudKit. I'd like both the free and paid apps to share the same data. Firstly is it possible for two apps to share the same data with CloudKit? If so, how can I get this to work? I've tried enabling CloudKit in the capabilities of both targets and selecting the same container in both apps. The main app which has 'Use default container' selected works fine, but the other app, on

Save CKServerChangeToken to Core Data

馋奶兔 提交于 2019-11-30 16:01:56
问题 I use CloudKit and Core Data with Swift to synchronize my data. Therefore I created Subscriptions and after getting a notification I fetch the new data from the cloud to update my Core Data. This is the recommended way to handle this update. For fetching data changes I can insert a CKServerChangeToken to fetch just the new stuff. My question is how to save the token to Core Data for later fetch requests? For CKRecords there is a method to save only the metadata but there isn't anything like

Limit the amount of results returned in CloudKit

寵の児 提交于 2019-11-30 14:04:10
Is there any way to limit the amount of results that are returned in a CKQuery ? In SQL , it is possible to run a query like SELECT * FROM Posts LIMIT 10,15 . Is there anything like the last part of the query, LIMIT 10,15 in CloudKit? For example, I would like to load the first 5 results, then, once the user scrolls down, I would like to load the next 5 results, and so on. In SQL, it would be LIMIT 0,5 , then LIMIT 6,10 , and so on. One thing that would work is to use a for loop, but it would be very intensive, as I would have to select all of the values from iCloud, and then loop through them

CloudKit notifications

若如初见. 提交于 2019-11-30 13:58:11
I might be missing something obvious here. How would one create a CloudKit notification with detail about the CKRecord that you are being notified about? (i.e. not just a generic "New Item Created!" but a notification with the title of the record for instance, like, "Jill and Jessica's Birthday Party!") Is the proper way to do this to create a new subscription with a new notification.alertBody for every new record change? That doesn't make any sense. That leaves the option queryNotification.recordID to pull the data out of CloudKit (or my local store) and add it to the notification somehow?

CloudKit not returning the most recent data

做~自己de王妃 提交于 2019-11-30 12:15:35
I am having this issue where I save something to the icloud using CloudKit but immediately fetching the results doesn't return the latest data inserted. Example let todoRecord = CKRecord(recordType: "Todos") todoRecord.setValue(todo, forKey: "todotext") publicDB.saveRecord(todoRecord, completionHandler: { (record, error) -> Void in NSLog("Saved in cloudkit") let predicate = NSPredicate(value: true) let query = CKQuery(recordType: "Todos", predicate: predicate) self.publicDB.performQuery(query, inZoneWithID: nil) { results, error in if error != nil { dispatch_async(dispatch_get_main_queue()) {

How to query by creationDate in CloudKit?

喜夏-厌秋 提交于 2019-11-30 11:45:18
I want to fetch the last X minutes of public/private entries from CloudKit. I tried something in this effect but failed: let date = NSDate(timeInterval: -60.0 * 120, sinceDate: NSDate()) let predicate = NSPredicate(format: "creationDate > %@", date) But this will get me data, but I'm not sure if I'm querying everything or just to some kind of cap: let predicate = NSPredicate(value: true) I want to be able to query by certain amount of time. Is this possible without doing the creation sorting logic on the client side? Here's the complete code block: func fetchPublicData(completion: ((records:

Check if User is Logged into iCloud? Swift/iOS

99封情书 提交于 2019-11-30 11:22:47
问题 Is there a way for me to check and see if a user is logged into iCloud when they open the app up? I want to be able to direct them to the settings page if they are not logged in, and if they are logged into iCloud and have used the app before - I want to skip the sign in page.... I looked into Apple's iCloud and Cloudkits documentation but was unable to find anything that would be of assistance! Is this even possible to do? 回答1: Here you go - hopefully self explanatory. For more look at the