如何设置 javapns(iOS 推送通知)?

发布于 2025-01-07 00:46:37 字数 231 浏览 2 评论 0原文

我查看了 javapns 的文档/wiki。 http://code.google.com/p/javapns/

不幸的是,本应显而易见的事情却并非显而易见我。

如何设置有效的推送通知服务器?例如,有一个 .jar 文件,但我希望获得更多信息。我需要在 Tomcat 中运行它吗?有可行的例子吗?

谢谢。

I have had a look at the documentation / wiki for javapns. http://code.google.com/p/javapns/

Unfortunately, what should be obvious is anything but obvious to me.

How do I set up a working push notification server? As in, there's a .jar file, but I would appreciate more info than that. Do I need to run this in Tomcat? Is there a working example?'

Thanks.

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

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

发布评论

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

评论(2

酷到爆炸 2025-01-14 00:46:37

我过去曾使用过 Java APNS 。它拥有 BSD 许可证,并且做得非常完美,并且一旦设置了证书就非常容易使用。总而言之,设置推送通知并不是一个非常简单的任务,但如果有任何东西还没有完全正常工作,我通常会得到可用的调试输出。

该解决方案的一个好处是,您可以单独运行它 java -jar MyAPNSPusher 并通过某些 cron 作业触发它,或者将逻辑包含在某些 .war 文件中。我还发现该库非常轻量级,我想您也可以在 Maven 存储库中找到它。

Readme.markdown 中的示例

要发送通知,您可以分两步完成:

  1. 设置连接

    ApnsService 服务 =
        APNS.newService()
        .withCert("/path/to/certificate.p12", "MyCertPassword")
        .withSandboxDestination()
        。建造();
    
  2. 创建并发送消息

    String Payload = APNS.newPayload().alertBody("不能比这更简单了!").build();
    字符串标记 =“fedfbcfb....”;
    service.push(令牌,有效负载);
    

[...]

替代方案

如果托管您自己的服务器解决方案太麻烦,那么您可以回退到第三方服务,这通常可能是一件好事因为托管运行此类服务的服务器可能经常被低估。使用这些服务,您通常需要为推送消息支付少量费用(几分之一美分)。我遇到的两个是

I have used Java APNS in the past. It has a BSD License and did a perfect job and was quite easy to use once the certificates were set up. All in all it is not a dead-simple task to set up Push notifications, but I usually got usable debug output if there was anything not quite working yet.

A good thing about this solution is that you can run it stand alone java -jar MyAPNSPusher and trigger it with some cron job or include the logic in some .war file. I also found that the library was quite lightweight and I guess you can also find it in a maven repo.

Example from the Readme.markdown

To send a notification, you can do it in two steps:

  1. Setup the connection

    ApnsService service =
        APNS.newService()
        .withCert("/path/to/certificate.p12", "MyCertPassword")
        .withSandboxDestination()
        .build();
    
  2. Create and send the message

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

[...]

Alternatives

If hosting your own server solution is too cumbersome then you can fallback to a thirdparty service which might often be a good thing because hosting a server with such a service running on it is probably often underestimated. With those services you usually pay a tiny amount (fractions of a cent) for a push message. Two that I have come across are

原谅我要高飞 2025-01-14 00:46:37

JavaPNS 是您的项目中使用的 java 库。它只能用于使用您在 Apple 开发人员工具网站上创建的证书连接到 Apple 推送通知服务器。

所以,如果我正确地阅读你的问题,这不是一个独立的程序,可能不是你想要的。

如果您尝试向 Apple iOS 设备发送推送通知,那么这就是您想要的,但您需要先编写应用程序的其余部分,然后向其中添加此库。

JavaPNS is a java library used within your project. It can only be used to connect to the Apple Push Notification Servers, using the certificates that you create on the Apple Developer Tools Website.

So, if I'm reading your question properly, this is not a stand-alone program and probably not what you want.

If you are trying to send push notifications to Apple iOS devices, then this IS what you want, but you need to write the rest of your application first, then add this library to it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文