iCloud Query Subscription - Multiple Notification for single Subscription

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 ?

Replies

A subscription is created by a user who is identified by the AppleID they used to log into iCloud; not the "admin" or the "agent". Whenever a user creates subscription, all devices logged into that same AppleID will get a notification if the subscription conditions are satisfied.

You are right that "A subscription is created by a user who is identified by the AppleID" but my issue is different. My is issue is when a user subscribe or other user subscribe then 1 notification fires. but when Admin and Agent use app and subscribe same as other users then 2 notification fired by icloud for single record change. Everything work perfect untill Agent and Admin apple id use app. When they use app, app code subscibe, 2 notification fired by icloud to all users.


Why this is happening, why 2 notification fired by icloud for single record change ?

"So there is 2 Users one is AGENT and other is ADMIN......When they use app, app code subscibe, 2 notification fired by icloud to all users."


Can you explain what "AGENT" and "ADMIN" are?