ios - Reset CKNotificationInfo badge value only for the current device -


i'm testing 3 idevices. device 1 fires cksubscription change notification.

device 2 , 3 receives notification , badge number increases 1.

i coded reset badge number 0 everytime app comes foreground below.(in applicationdidbecomeactive:)

ckmodifybadgeoperation *badgeresetoperation = [[ckmodifybadgeoperation alloc] initwithbadgevalue:0]; [badgeresetoperation setmodifybadgecompletionblock:^(nserror * operationerror) {     if (!operationerror) {         [uiapplication sharedapplication].applicationiconbadgenumber = 0;     } }]; [[ckcontainer defaultcontainer] addoperation:badgeresetoperation]; 

if user taps app on device 2, above code executed. works well. badge number reset 0. issue badge number on device 3 become 0 simultaneously, though didn't tap app on device 3.

i hope device 3 remains increased badge number since user didn't tap it.

api reference says 'this operation object can update badge current device or of user’s devices.'

https://developer.apple.com/reference/cloudkit/ckmodifybadgeoperation?language=objc

i believe means there's way reset single device want.

please guide me how accomplish it.

if 3 devices logged in same icloud id share same badge count. badges stored onto user's icloud account. why same across every device logged account.

log other devices on different icloud accounts , run test again. should work.

also, when saving subscriptions make sure saving same multiple times otherwise multiple badges same notification. check existence of subscription before saving again.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -