如果记录所有者是自己,则 CKSubscription 不起作用

CKSubscription not working if record owner is self

如果我使用 CKDatabase.saveRecord 创建 CKRecord,当我自己插入该记录时,不会触发 CKSubscription 通知。显然我只有在其他人插入记录时才会收到通知,但我希望统一接收通知,无论记录是由我还是其他人创建的。

此外,我没有在文档中找到关于此行为的提及。

在同一台设备上创建记录后,我尝试了很长时间来接收通知,但只有在仪表板中创建人工记录后,它才最终起作用。

是否有更改此行为的标志?

您只会收到有关在设备外创建、删除或修改的记录的订阅通知。如果您 insert/change/delete 设备上有记录,则需要直接处理。

来自 Cloud Kit Quick Start 指南(已添加重点)

Test Subscriptions

You can initially test subscriptions by running your app through Xcode and using CloudKit Dashboard to create, modify, or delete records, as described in Add, Modify, and Delete Records. Then fully test subscriptions by running your app on multiple devices. Use one device to make changes and another device to receive the subscription notifications. You use multiple devices because a notification isn’t sent to the same device that originated the notification