你如何设置javapns(iOS的推送通知)? [英] How do you set up javapns (push notifications for iOS)?

查看:374
本文介绍了你如何设置javapns(iOS的推送通知)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

如何设置工作推送通知服务器?就像在,有一个.jar文件,但我会感谢更多的信息。我需要在Tomcat中运行吗?是否有一个有效的例子?'

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?'

谢谢。

推荐答案

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

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.

一个好的关于这个解决方案的事情是你可以独立运行 java -jar MyAPNSPusher 并用一些cron作业触发它或在某些中包含逻辑.war 文件。我还发现该库非常轻巧,我想你也可以在maven回购中找到它。

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.

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

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


  1. 设置连接

  1. 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);
    


  • [.. 。]

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

    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


    编辑截至7月2011年1月,iLime API已作为公共服务停止使用。

    Edit As of July 1, 2011, the iLime API has been discontinued as a public service.


  • http://urbanairship.com/

  • http://urbanairship.com/
  • 这篇关于你如何设置javapns(iOS的推送通知)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆