最初のデバイスで変更(たとえば40レコード追加)を実行すると、2番目のデバイスに40 CKQueryNotifications
が表示されることがあります。CloudKitのCKNotificationとCKQueryNotificationの違いは何ですか?
私はCKQueryNotifications
と読むことができますが、私は読むとしてCKNotifications
とマークすることはできません。どうして?すべての起動後、常にデバイスに戻ってきます。どうして?
どのように保留中の通知を取得しますか?私は、読み取りとして通知をマークするにはどうすればよい
var serverChangeToken: CKServerChangeToken? {
return UserDefaults(suiteName: SharedGroupName)?.object(forKey: "a") as? CKServerChangeToken
}
func fetchPendingNotifications(notifications: [CKNotification] = [], completion: ErrorHandler? = nil) {
var queryNotifications = notifications
let operation = CKFetchNotificationChangesOperation(previousServerChangeToken: serverChangeToken)
let operationQueue = OperationQueue()
operation.notificationChangedBlock = { notification in
print("+++++ \(notification)")
queryNotifications.append(notification)
}
operation.fetchNotificationChangesCompletionBlock = { token, error in
if let token = token {
UserDefaults(suiteName: SharedGroupName)?.set(NSKeyedArchiver.archivedData(withRootObject: token), forKey: "a")
UserDefaults(suiteName: SharedGroupName)?.synchronize()
}
if error == nil && operation.moreComing {
self.fetchPendingNotifications(notifications: queryNotifications, completion: completion)
} else {
self.perform(queryNotifications: queryNotifications, completion: completion)
}
}
operationQueue.addOperation(operation)
}
?
func perform(queryNotifications: [CKNotification], completion: ErrorHandler? = nil) {
var currentQueryNotifications = queryNotifications
if let queryNotification = currentQueryNotifications.first {
currentQueryNotifications.removeFirst()
let operation = CKMarkNotificationsReadOperation(notificationIDsToMarkRead: [queryNotification.notificationID!])
operation.markNotificationsReadCompletionBlock = { _, _ in
print("marked as read")
self.perform(queryNotifications: currentQueryNotifications, completion: completion)
}
OperationQueue().addOperation(operation)
} else {
completion?(nil)
}
}
コンソールの出力は何ですか?
+++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> +++++ , containerIdentifier=iCloud.pl.blueworld.fieldservice, badge=0> marked as read marked as read marked as read marked as read marked as read marked as read marked as read marked as read marked as read marked as read marked as read marked as read marked as read marked as read
あなたのコードを読んだものとしてマークした場所で共有することはできますか? –
@DaveWeston私は質問 –