<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CloudKit",
  "identifier" : "/documentation/CloudKit/CKQueryNotification",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "CloudKit"
    ],
    "preciseIdentifier" : "c:objc(cs)CKQueryNotification"
  },
  "title" : "CKQueryNotification"
}
-->

# CKQueryNotification

A notification that triggers when a record that matches the subscription’s predicate changes.

```
class CKQueryNotification
```

## Overview

Query subscriptions execute when a record that matches the subscription’s predicate changes, for example, when the user modifies a field’s value in the record. When CloudKit registers the change, it sends push notifications to the user’s devices to inform your app about the change. You can then fetch the changes and cache them on-device. When appropriate, CloudKit excludes the device where the change originates.

You configure a subscription’s notifications by setting its [`notificationInfo`](/documentation/CloudKit/CKSubscription/notificationInfo-swift.property) property. Do this before you save it to the server. A subscription generates either high-priority or medium-priority push notifications. CloudKit delivers medium-priority notifications to your app in the background. High-priority notifications are visual and the system displays them to the user. Visual notifications need the user’s permission. For more information, see <doc://com.apple.documentation/documentation/UserNotifications/asking-permission-to-use-notifications>.

A subscription uses [`CKSubscription.NotificationInfo`](/documentation/CloudKit/CKSubscription/NotificationInfo-swift.class) to configure its notifications. For background delivery, set only its [`shouldSendContentAvailable`](/documentation/CloudKit/CKSubscription/NotificationInfo-swift.class/shouldSendContentAvailable) property to <doc://com.apple.documentation/documentation/Swift/true>. If you set any other property, CloudKit treats the notification as high-priority.

> Note: To receive silent push notifications, add the Background Modes capability to your Xcode project, and select the “Background fetch” and “Remote notifications” options.

Don’t rely on push notifications for changes because the system can coalesce them. CloudKit can omit data to keep the notification’s payload size under the APNs size limit. If you use [`desiredKeys`](/documentation/CloudKit/CKSubscription/NotificationInfo-swift.class/desiredKeys) to include extra data in the payload, the server removes that first. A notification’s [`isPruned`](/documentation/CloudKit/CKNotification/isPruned) property is <doc://com.apple.documentation/documentation/Swift/true> if CloudKit omits data.

Consider notifications an indication of remote changes. Use [`databaseScope`](/documentation/CloudKit/CKDatabaseNotification/databaseScope) to determine which database contains the changed record. To fetch the changes, configure an instance of [`CKQueryOperation`](/documentation/CloudKit/CKQueryOperation) to match the subscription and then execute it in the database. CloudKit returns all records that match the predicate, including the changed record. Dispose of any records you cache on-device and use the operation’s results instead.

You don’t instantiate this class. Instead, implement <doc://com.apple.documentation/documentation/UIKit/UIApplicationDelegate/application(_:didReceiveRemoteNotification:fetchCompletionHandler:)> in your app delegate. Initialize [`CKNotification`](/documentation/CloudKit/CKNotification) with the `userInfo` dictionary that CloudKit passes to the method. This returns an instance of the appropriate subclass. Use the [`notificationType`](/documentation/CloudKit/CKNotification/notificationType-swift.property) property to determine the type. Then cast to that type to access type-specific properties and methods.

## Topics

### Getting the Database Scope

[`databaseScope`](/documentation/CloudKit/CKQueryNotification/databaseScope)

The type of database for the record zone.

### Getting the Notification Attributes

[`queryNotificationReason`](/documentation/CloudKit/CKQueryNotification/queryNotificationReason)

The event that triggers the push notification.

[`CKQueryNotification.Reason`](/documentation/CloudKit/CKQueryNotification/Reason)

Constants that indicate the event that triggers the notification.

### Getting the Record Information

[`recordID`](/documentation/CloudKit/CKQueryNotification/recordID)

The ID of the record that CloudKit creates, updates, or deletes.

[`recordFields`](/documentation/CloudKit/CKQueryNotification/recordFields)

A dictionary of fields that have changes.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)