如何使用Javapns支持Apple的增强通知格式

发布于 2024-11-04 01:33:59 字数 528 浏览 3 评论 0原文

您好,

我正在创建一个基于 Java 的服务器来为 Apple 的 iOS APNs 服务创建推送通知。我在 google code 上发现了 Javapns,它似乎提供了一个简单的基本框架来与 APN 进行通信,并且似乎得到了相当广泛的使用。

http://code.google.com/p/javapns/

但是,阅读Apple的文档,通知有一种“增强格式”,支持“过期”,即设置通知在尚未发送时过期的时间(以秒为单位)。我没有看到任何使用 Javapns 进行设置的方法,并且如果您没有明确设置它,我不确定 APNs 服务如何处理通知到期。那么,

  1. 有谁知道如何支持 APNs 的增强通知格式,具体如何设置过期时间?
  2. 有谁知道如果没有明确设置Apple如何处理通知到期?
  3. 由于服务器当前正常运行,有人有任何建议不需要我从头开始吗?

提前致谢。

安德鲁

Greetings,

I am creating a Java based server to create push notifications for Apple's iOS APNs service. I have found Javapns on google code which seems to provide a simple basic framework to communicate with APNs, and which seems to be fairly wide used.

http://code.google.com/p/javapns/

However, reading Apple's docs, there is an "enhanced format" for notifications which supports "expiry" i.e. setting a time (well, in seconds) for a notification to expire if it hasn't yet been delivered. I do not see any way to set this using Javapns, and I am unsure how the APNs service handles expiry of notifications if you do not explicitly set it. So,

  1. Does anyone know how to support the enhanced notification format of APNs specifically how to set the expiry?
  2. Does anyone know how Apple handles notification expiry if it isn't explicitly set?
  3. Does anyone have any suggestions that don't require me to start from scratch, as the server is currently functional as is?

Thanks in advance.

Andrew

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淡笑忘祈一世凡恋 2024-11-11 01:33:59

我最近为 JavaPNS 项目做出了重大贡献,这导致了几天前 JavaPNS 2.0 的发布。该版本提供对增强通知格式的全面支持,包括设置您自己的到期时间的能力。

西尔万

I have recently made substantial contributions to the JavaPNS project, which lead to the release of JavaPNS 2.0 a few days ago. That version provides full support for the enhanced notification format, including the ability to set your own expiry.

Sylvain

围归者 2024-11-11 01:33:59

很高兴您找到了 java 库...可惜您没有阅读那里的文档。

我将在下面发布一些要点:


现有代码使用“简单通知格式”,它永远不会返回错误。

请参阅以下位置的文档:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html

我已尝试更新为“增强型通知格式”它应该返回一个错误,但我无法从 APNS 返回任何错误。 (也在上面的链接中)

使用增强格式,发送数据后连接不会立即断开,但我没有从 socket.getInputSocket.read() 调用中得到任何信息。

这个问题必须先搁置起来,直到我有更多时间进行故障排除。

(还有人评论)
非常感谢您的调查。
我得到了和你一样的结果。可能和Apple Gateway有关系。


所以...你可以:
1)建立你自己的
2)帮助改进现有库
3)尝试另一个库,例如: https://github.com/notnoop/java-apns
4)什么也不做

Nice that you found the java library... to bad you didn't read the docs there.

I'll post some of the highlights below:


The existing code uses the 'Simple notification format' which does not return an error EVER.

See docs at:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html

I've tried updating to the 'Enhanced notification format' which is supposed to return an error, but I'm unable to get any errors back from the APNS. (also in the link above)

With the Enhanced format, the connection isn't being dropped immediately after sending data, but I'm not getting anything back from my socket.getInputSocket.read() call.

This issue will have to be tabled until I have more time to troubleshoot.

(Someone else commented)
Thanks a lot for looking into it.
I got the same result as yours. Maybe it has something to do with Apple Gateway.


So... you could:
1) Build your own
2) Help improve the existing library
3) Try another library like: https://github.com/notnoop/java-apns
4) Do nothing

鹿港小镇 2024-11-11 01:33:59

增强型 ios 推送此处
要发送通知,您可以通过三个步骤完成:

设置连接

ApnsService service =
    APNS.newService()
    .withCert("/path/to/certificate.p12", "MyCertPassword")
    .withSandboxDestination()
    .build();

创建并发送消息

String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
String token = "fedfbcfb....";
service.push(token, payload);

查询非活动设备的反馈服务:

Map<String, Date> inactiveDevices = service.getInactiveDevices();
for (String deviceToken : inactiveDevices.keySet()) {
    Date inactiveAsOf = inactiveDevices.get(deviceToken);
    ...
}

Enhanced ios push here.
To send a notification, you can do it in three steps:

Setup the connection

ApnsService service =
    APNS.newService()
    .withCert("/path/to/certificate.p12", "MyCertPassword")
    .withSandboxDestination()
    .build();

Create and send the message

String payload = APNS.newPayload().alertBody("Can't be simpler than this!").build();
String token = "fedfbcfb....";
service.push(token, payload);

To query the feedback service for inactive devices:

Map<String, Date> inactiveDevices = service.getInactiveDevices();
for (String deviceToken : inactiveDevices.keySet()) {
    Date inactiveAsOf = inactiveDevices.get(deviceToken);
    ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文