I made a code to save a subscription in public database. Its working perfectly
I have Organization account. And I added a User with Admin Role.
So there is 2 Users one is AGENT and other is ADMIN.
When AGENT Run the app with agent apple id and subcribe to a icloud database change notification, it will work and every user who subscibed receive 1 notification for single record change.
But now When User with ADMIN Role with admin apple id Subscribe for Notification. Every user receive 2 Notification for single record change
let predicate = NSPredicate(format: "appName = %@", "Alpha")
let subscription = CKQuerySubscription(recordType: "appURL", predicate: predicate, subscriptionID: "IOS-Pub-appURL-AlphaURL-Subscription", options: [.firesOnRecordCreation,.firesOnRecordDeletion,.firesOnRecordUpdate])
let notificationInfo = CKSubscription.NotificationInfo()
notificationInfo.title = "Content Updated"
notificationInfo.alertBody = "Updated content had been released so can we go ahead and load it now, please."
notificationInfo.shouldSendContentAvailable = true
notificationInfo.desiredKeys = ["appMainURL"]
subscription.notificationInfo = notificationInfo
CKContainer.default().publicCloudDatabase.save(subscription) { (subscription
, error) in
if error == nil {
print("PublicAppUrlAplhaSubscription saved successfully")
UDKeys.isFeedNotificationSubscribed = true
} else {
print("PublicAppUrlAplhaSubscription " + (error?.localizedDescription)!)
}
}
Also when ADMIN delete this subscription from icloud Dashboard Subscription list then All users receive 1 notification for the single record change.
My question is iCloud Public database is creating 2 Subsciption with Same Subscription ID. One with ADMIN account id and one with AGENT account id.
Or its a bug in icloud ?