[ACCEPTED]-Push-Notification Badge auto increment-push-notification
Nope, you'll have to track this on the server 10 side. If you don't include any value for 9 badge, it will get removed completely.
Of 8 course though this is only if the user receives 7 the notification and the app isn't running/they 6 choose not to launch it. If the user launches 5 the app or already had it running you can 4 do whatever you want in regards to incrementing.
UPDATE March 2014: See 3 comments for a possible update. I haven't 2 done pushes in several years so haven't 1 been able to verify this myself.
It's sort of possible but there's a trade-off.
You 14 can always send up the unread total as an 13 add-on JSON value as part of the push payload 12 (push ignores keys it doesn't explicitly 11 understand). Once the user opens the app, read 10 the value and adjust the badge programmatically 9 yourself via UIApplication's applicationIconBadgeNumber
property.
The 8 problem with doing it that way is that push 7 adjusts the badge value even if the user 6 doesn't open the app (i.e. when they get 5 the notice and the user hits 'Cancel' instead 4 of 'View'). In those cases your badge won't 3 change, but as soon as they run the app 2 (if they hit 'View') then your app can set 1 it right.
You can try out App42 backend services which 24 provide auto increment of push badge count 23 which is maintained on the server side. For 22 more details you can follow the link of 21 blog. Here is the blogpost conent:
Here are the 20 few use cases that can be achieved through 19 auto incremental badge count in App42 Push 18 Notification.
For auto increment of push 17 badge by 1, you need to send push message 16 as shown below.
PushNotificationService pushNotificationService = App42API.BuildPushNotificationService (); // Initializing PushNotification Service.
string userName = "UserName";
string message= "{'badge':'increment'}";
pushNotificationService.SendPushMessageToUser(userName,message, new UnityCallBack())
N.B: The sample explained 15 is for Unity/C# but the same process can 14 be applied on others too.
If you want to 13 stipulate any number for the badge or want 12 to reduce the badge count to zero, you can 11 use this method to update the count as the 10 notification gets clicked by the user. You 9 have to call updatePushBadgeforDevice or 8 updatePushBadgeforUser in this case.
PushNotificationService pushNotificationService = App42API.BuildPushNotificationService (); // Initializing PushNotification Service.
string userName = "UserName";
string deviceToken = "DeviceToken";
int badges = 10; // For clear count make it 0
pushNotificationService.UpdatePushBadgeforDevice(userName, deviceToken, badges, new UnityCallBack());
PushNotificationService pushNotificationService = App42API.BuildPushNotificationService (); // Initializing PushNotification Service.
string userName = "UserName";
int badges = 10; // For clear count make it 0
pushNotificationService.UpdatePushBadgeforUser(userName, badges, new UnityCallBack());
updatePushBadgeforDevice
– This 7 method is used to update push badge count 6 of a particular device registered by the 5 user .
updatePushBadgeforUser
– This method is used to update push 4 badge count of all the devices that a user 3 procures. In this case, we are assuming 2 that the user has multiple devices registered 1 under his name.
It is now possible to have the client auto-increment 8 the badge using a UNNotificationServiceExtension.
Extensions 7 have the ability to modify notification 6 payloads before iOS displays them. In summary, store 5 a badge counter in UserDefaults and modify 4 the notification's badge count as needed. You'll 3 need to add the App Groups capability to 2 share User Defaults.
Here's a detailed step-by-step 1 guide: https://prodocs.cometchat.com/docs/ios-increment-app-icon-badge-count
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.