Unable to set header field “apns-push-type” in Apple Push Notification in javapns

て烟熏妆下的殇ゞ 提交于 2020-06-01 02:36:05

问题


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.

来源:https://stackoverflow.com/questions/59151384/unable-to-set-header-field-apns-push-type-in-apple-push-notification-in-javapn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!