我有一个向 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;
}
一切都按预期工作。今天,作为增强功能的一部分,我需要在 http 标头中发送“apns-push-type”,这是 iOS 13+ 所要求的。
“apns-push-type”的 Apple 开发人员文档链接
我找不到任何选项(方法、类等)来使用 apns 库设置 http 标头信息。
下面是我的项目中用于 apns jar 的类路径条目,
<classpathentry kind="lib" path="src/main/webapp/WEB-INF/lib/apns-1.0.0.Beta6.jar"/>
请帮助我。我搜索了互联网,stackoverflow,但没有找到任何线索。