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
Post a Comment