CloudKit: subscription for deleting record does not work
| Originator: | kaskaaddnb | ||
| Number: | rdar://18810914 | Date Originated: | Oct 6 at 17:59 |
| Status: | Open | Resolved: | Not |
| Product: | iOS, CloudKit SDK | Product Version: | iOS 8.1 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
CKSubscription doc says: When a record modification causes a subscription to fire, the server sends push notifications to all devices with that subscription except for the one that made the original change to the record.
Let assume I have two devices: device 1 and device 2 logged in from different iCloud accounts. Let assume both devices subscribed for record deletion for a certain record type.
If device 1 creates a record and then device 1 deletes it then device 2 get notified - THAT IS ACCORDING TO THE DOC, BUT ..
If device 1 creates a record and then device 2 deletes it then device 2 get notified - I do NOT think it is ACCORDING TO THE DOC, and IT DOES NOT MAKE ANY SENSE, device 2 deleted it so device 1 should be notified
Steps to Reproduce:
SET UP SUBSCRIPTION ON DEVICE 1 AND DEVICE 2
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Alert, categories: nil))
application.registerForRemoteNotifications()
let defaultContainer = CKContainer.defaultContainer()
let publicDatabase = defaultContainer.publicCloudDatabase
publicDatabase.fetchAllSubscriptionsWithCompletionHandler({subscriptions, error in
if error == nil {
if subscriptions.count == 0 {
let subscription = CKSubscription(recordType: "OU", predicate: NSPredicate(value: true), options: .FiresOnRecordDeletion)
subscription.notificationInfo = CKNotificationInfo()
subscription.notificationInfo.shouldBadge = false
subscription.notificationInfo.alertBody = "OU removed or upated"
publicDatabase.saveSubscription(subscription, completionHandler: {subscription, error in
if error == nil {
} else {
println("\(error.localizedDescription)")
}
})
}
} else {
println("\(error.localizedDescription)")
}
})
return true
}
CREATE RECORD on DEVICE 1
@IBAction func addOU(sender: AnyObject) {
var defaultContainer = CKContainer.defaultContainer()
var publicDatabase = defaultContainer.publicCloudDatabase
let r = CKRecord(recordType: "OU", recordID: CKRecordID(recordName: "aaaa"))
publicDatabase.saveRecord(r, completionHandler: { r2, error in
if error == nil {
} else {
println("\(error.localizedDescription)")
}
})
}
DELETE RECORD ON DEVICE 2
@IBAction func removeOU(sender: AnyObject) {
var defaultContainer = CKContainer.defaultContainer()
var publicDatabase = defaultContainer.publicCloudDatabase
publicDatabase.deleteRecordWithID(CKRecordID(recordName: "aaaa"), completionHandler: {recordID, error in
if error == nil {
} else {
println("\(error.localizedDescription)")
}
})
}
Expected Results:
device 2 deletes and device 1 should be notified
Actual Results:
device 2 deletes and device 2 get notified
Version:
iOS 8.1
Notes:
Configuration:
iPhone 5
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!