0

I am using java-apns library. Here is my code:

 String payload = APNS.newPayload().alertBody("Message").badge(2).build();

 apnsService.push(tokens, payload);

Why there is many tokens and only one number for badge? Each phone has its own number of unread notifications! So there should be one number for one device. How do I get to be so?

p.s. sorry for my english.

Community
  • 1
  • 1

1 Answers1

0

The apnsService.push(tokens, payload) method is used for sending the exact same payload to multiple devices. If you wish to send a different payload to each device (and different badge counts mean different payload), you'll have to create a different payload for each device and call the push method for each device token separately (there's probably a version of that method that takes just a single device token).

Eran
  • 387,369
  • 54
  • 702
  • 768
  • thanks for reply! But how will this affect performance? Should I make an asynchronous posting or there is no point? –  Aug 11 '14 at 12:53
  • @brandly I don't know what you mean by `asynchronous posting`. I don't use java-apns. If you a referring to using multiple connections and multiple threads to send the notifications concurrently, then yes, it would improve your performance. But first, check the performance of your current implementation. Perhaps it's already good enough for you. – Eran Aug 11 '14 at 12:57