1

I have a legacy code which send notifications to iOS.

public List<NotificationResponse> sendNotifications(Constants.App app, List<String> deviceTokens, String payload,
        List<String> userId, String sender, String appKey) {
    List<NotificationResponse> response = new ArrayList<NotificationResponse>();
    String keystore = serviceKeyMap.get(app).getApiServiceKey();
    String password = serviceKeyMap.get(app).getPassword();
    String toUser = StringUtils.EMPTY;
    Integer appId = NotificationHistoryHelper.getAppMap().get(appKey);
    if (!CollectionUtils.isEmpty(userId)) {
        toUser = userId.get(0);
    }
    try {
        LOGGER.info("Multicasting payload: {} to devices: {}", new Object[] { payload, deviceTokens });
        ApnsService service;
        ApnsServiceBuilder serviceBuilder = APNS.newService().withCert(keystore, password)
                .withProductionDestination();
        if (deviceTokens.size() == 1) {
            serviceBuilder.withDelegate(new ApnsDelegateImpl(deviceTokens.get(0), payload,
                    notificationHistoryService, toUser, sender, appId));
        }
        service = serviceBuilder.build();
        service.push(deviceTokens, payload);
    } catch (Exception e) {
        LOGGER.error("Exception while sending notification to multiple devices", e);
    }
    return response;
}

Everything is working as expected. Today, as part of an enhancement, I need to send "apns-push-type" in the http header, which is required by iOS 13+.

Apple Developer Document link for "apns-push-type"

I am unable to find any option (method, class, etc.) to set http header information using apns library.

Below is the classpath entry in my project for the apns jar,

<classpathentry kind="lib" path="src/main/webapp/WEB-INF/lib/apns-1.0.0.Beta6.jar"/>

Please help me in this. I have scoured the internet, stackoverflow, but didn't find any clues.

Rishav Raj
  • 11
  • 1

0 Answers0