Re: Closing APNS Client

Skip to first unread message
Message has been deleted

Vijaya Kumari Katta

Oct 11, 2020, 10:49:45 AM10/11/20
to pushy
If the screenshot is not visible, Please look here

for (final SimpleApnsPushNotification pushNotification : pushNotificationList) {

final PushNotificationFuture<SimpleApnsPushNotification,PushNotificationResponse<SimpleApnsPushNotification>> sendNotificationFuture = client.sendNotification(pushNotification);

sendNotificationFuture.whenComplete((response, cause) -> {

    if(response != null) {

    if (response.isAccepted()) {"Push notification accepted by APNs gateway for apnsId ="+response.getApnsId() );

        } else {"Notification rejected by the APNs gateway: " +


            response.getTokenInvalidationTimestamp().ifPresent(timestamp -> {

  "\t…and the token is invalid as of " + timestamp);



    } else {

    logger.error("error ");




final CompletableFuture<Void> closeFuture = client.close();

On Sunday, October 11, 2020 at 7:47:54 AM UTC-7 Vijaya Kumari Katta wrote:
Hi All, 

This is very Important for me. Please I need your help on this.  I am new to pushy . 

Currently my requirement is to send notification to 15,000 devices at a time. I have few challenges to make my implementation successful. 

1. As Im using completable future for notification response acknowledgement(15k notifications) , Is there a way I could know when the last acknowledgement is received. 

2. Do I need to wait for acknowledgement to be received before I close the client. Or should I just care about just sending 15 K notifications and close the client? 

3. Do I need to add listeners if i am using completable future to track response?

4. I want to save my responses into the database. Is it possible? 

5. Can you suggest any thing for below implementatin?

Help is greatly appreciated. I really need to nail this down. Please need some suggestions. 


Petr Dvořák

Oct 11, 2020, 11:00:04 AM10/11/20
to pushy

1) Have a look at Phaser for synchronization. Phaser will allow you to wait until the last message is sent. This is how we use it (we do so for both APNS and FCM notification, but the gist is hopefully clear):

2) Phaser will solve this for you, you will close the client after the notifications are sent.

3) No, just use a completable future.

4) Yes, but this is the work you need to do, Pushy will not help you with this.

5) Yes, create a "new Phaser(1)" in the beginning, register it when sending the push by "phaser.register()", deregister it inside the completable future callback by "phaser.arriveAndDeregister()", and finally let the code advance by "phaser.arriveAndAwaitAdvance()" before closing the client.

Reply all
Reply to author
0 new messages