我正在创建两个CKDatabaseSubscription
,一个用于privateCloudDatabase
,一个用于sharedCloudDatabase
,如下所示:
// Subscription to private database //
CKDatabaseSubscription *privateSubscription = [[CKDatabaseSubscription alloc] initWithSubscriptionID:@"checkPrivateDatabaseChanges"];
CKNotificationInfo *privateNotificationInfo = [[CKNotificationInfo alloc] init];
privateNotificationInfo.shouldSendContentAvailable = true;
privateNotificationInfo.alertBody = @"private database subscription";
privateSubscription.notificationInfo = privateNotificationInfo;
CKModifySubscriptionsOperation *privateSubscriptionModify = [[CKModifySubscriptionsOperation alloc] initWithSubscriptionsToSave:[NSArray arrayWithObject:privateSubscription] subscriptionIDsToDelete:nil];
[[CKContainer defaultContainer].privateCloudDatabase addOperation:privateSubscriptionModify];
//
// Subscription to Shared database //
CKDatabaseSubscription *sharedSubscription = [[CKDatabaseSubscription alloc] initWithSubscriptionID:@"checkSharedDatabase"];
CKNotificationInfo *sharedNotificationInfo = [[CKNotificationInfo alloc] init];
sharedNotificationInfo.shouldSendContentAvailable = true;
sharedNotificationInfo.alertBody = @"shared database subscription";
sharedSubscription.notificationInfo = sharedNotificationInfo;
CKModifySubscriptionsOperation *sharedSubscriptionModify = [[CKModifySubscriptionsOperation alloc] initWithSubscriptionsToSave:[NSArray arrayWithObject:sharedSubscription] subscriptionIDsToDelete:nil];
[[CKContainer defaultContainer].sharedCloudDatabase addOperation:sharedSubscriptionModify];
//
一切正常,我收到有关更改的通知,但是即使将这些订阅从代码中删除并从cloudkit仪表板中删除,它们似乎仍会发送通知。
实际上,一个星期前删除的旧测试订阅仍在发送带有测试警报的通知。 我不愿意重置CloudKit容器,但这是否是正确重置订阅的唯一方法?