我正在关注关于添加订阅的“CloudKit 最佳实践”WWDC 讨论,这似乎在 iOS10 中发生了变化。
下面的代码返回“成功!”,但是我的“AllChanges”订阅从未出现在 CloudKit 仪表板上的订阅类型中。
我在 Xcode 8 beta 6 上。
let subscription = CKDatabaseSubscription(subscriptionID:"AllChanges")
let notificationInfo = CKNotificationInfo()
notificationInfo.shouldSendContentAvailable = true
subscription.notificationInfo = notificationInfo
let operation = CKModifySubscriptionsOperation(subscriptionsToSave: [subscription], subscriptionIDsToDelete: [])
operation.modifySubscriptionsCompletionBlock = {
(modifiedSubscriptions: [CKSubscription]?, deletedSubscriptionIDs: [String]?, error: Error?) -> Void in
if error != nil {
print(error!.localizedDescription)
} else {
print("Success!")
}
}
operation.qualityOfService = .utility
privateDatabase.add(operation)