Class

CKFetchNotificationChangesOperation

An operation that is used to retrieve unread notifications from a CloudKit container.

Overview

Notification objects contain the data associated with push notifications that have already been sent to an app. Fetch notification objects to identify changes that your app might have missed or to retrieve the complete push notification payload, which might have been truncated when it was delivered to the device.

A CKFetchNotificationChangesOperation object retrieves unread CKNotification objects from a container. Notification objects contain the data associated with push notifications that have already been sent to an app. Fetch notification objects to identify changes that your app might have missed or to retrieve the complete push notification payload, which might have been truncated when it was delivered to the device.

After fetching the current notifications, you can mark some or all of them as read using a CKMarkNotificationsReadOperation object. Marking a notification as read prevents it from being returned by subsequent fetch operations.

The blocks you assign to process the fetched notifications are executed serially on an internal queue that is managed by the operation object. Your blocks must be capable of executing on a background thread, so any tasks that require access to the main thread must be redirected accordingly.

If you assign a completion block to the completionBlock property of the operation object, the completion block is called after the operation executes and returns its results to you. You can use a completion block to perform housekeeping chores related to the operation, but do not use it to process the results of the operation itself. Any completion block you specify should be prepared to handle the failure of the operation to complete its task, whether due to an error or an explicit cancellation.

Topics

Initializing the Operation Object

init(previousServerChangeToken: CKServerChangeToken?)

Initializes and returns an operation object set to fetch notification changes.

Configuring the Operation Object

var previousServerChangeToken: CKServerChangeToken?

The change token from a previous fetch operation.

var resultsLimit: Int

The maximum number of results to fetch with this operation.

Processing the Operation Results

var moreComing: Bool

A Boolean value indicating that more notifications are waiting to be delivered.

var notificationChangedBlock: ((CKNotification) -> Void)?

The block that processes a single push notification.

var fetchNotificationChangesCompletionBlock: ((CKServerChangeToken?, Error?) -> Void)?

The block that is executed after all requested notifications are fetched.

Relationships

Inherits From

Conforms To

See Also

Notification Operations

class CKMarkNotificationsReadOperation

An operation that marks push notifications as read by your app.

Deprecated