Question

I am using java-apns library. JavaDoc for method badge from PayloadBuilder class states that:

Sets the notification badge to be displayed next to the application icon. The passed value is the value that should be displayed (it will be added to the previous badge number), and badge of 0 clears the badge indicator.

However, passing always 1 to method does not increment badge number on application icon. It's stuck on 1 (or on the number I pass).

Is it possible to solve that or documentation is wrong? I do not want to keep server-side how many unread notifications are on client and manage that number on my own as work-around. Since I know that notifications can be discarded by Apple if device is not reachable for a long time and so is easy to get out of synch.

An example of my code:

PayloadBuilder payloadBuilder = APNS.newPayload().alertBody("Test message");
payloadBuilder.actionKey("OK");
payloadBuilder.badge(1);

and JSON payload from console:

Payload={"aps":{"alert":{"body":"Test message","action-loc-key":"OK"},"badge":1}}
Was it helpful?

Solution

you need to include the "badge" in your payload, it doesn't get accumulated.

I guess you need to set: payloadBuilder.badge(15); // 15 is the total

See this apple doc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top