Response time from APNS

100 views
Skip to first unread message

Saranyu Ngaosri

unread,
Oct 28, 2020, 7:15:09 AM10/28/20
to pushy
Hello everyone, I have a question about response time from APNS, 
I am trying to send VOIP notification with pushy and this lib works fine But it takes about 20-23 seconds to get the response.
Before, I  tried to send notifications by CURL and got quickly response.

And this is my code

public String sendNotification() throws Exception {
String respon_result = "";
File cert_file = new File("/Certificates2.p12");
final ApnsClient apnsClient = new ApnsClientBuilder().setApnsServer(ApnsClientBuilder.DEVELOPMENT_APNS_HOST)
.setClientCredentials(cert_file, "*******").build();
final ApnsPayloadBuilder payloadBuilder = new SimpleApnsPayloadBuilder();

payloadBuilder.setAlertTitle("Test Voip");
payloadBuilder.setAlertBody("Test Voip by pushy");
payloadBuilder.setBadgeNumber(1);
payloadBuilder.setSound("default");
payloadBuilder.setCategoryName("call");
payloadBuilder.setContentAvailable(true);

final String payload = payloadBuilder.build();

final String token = "******";
final String topic = "";

System.out.println("Payload: " + payload );
final SimpleApnsPushNotification pushNotification = new SimpleApnsPushNotification(token, topic, payload, null,
null, PushType.VOIP);


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

try {
final PushNotificationResponse<SimpleApnsPushNotification> pushNotificationResponse = sendNotificationFuture
.get();

if (pushNotificationResponse.isAccepted()) {
System.out.println("Push notification accepted by APNs gateway.");
System.out.println("Push notification APNS-ID: " + pushNotificationResponse.getApnsId().toString());
respon_result = "Push notificationaccepted by APNs gateway." + "\n" + "Push notification APNS-ID: "
+ pushNotificationResponse.getApnsId().toString();
} else {s
System.out.println(
"Notification rejected by the APNs gateway: " + pushNotificationResponse.getRejectionReason());

pushNotificationResponse.getTokenInvalidationTimestamp().ifPresent(timestamp -> {
System.out.println("\t…and the token is invalid as of " + timestamp);
});

respon_result = "Notification rejected by the APNs gateway: "
+ pushNotificationResponse.getRejectionReason();
}
} catch (final ExecutionException e) {
System.err.println("Failed to send push notification.");
e.printStackTrace();
respon_result = "Failed to send push notification.";
} finally {
return respon_result;
}

}
Reply all
Reply to author
Forward
0 new messages