java ios push,你如何设置javapns(iOS的推送通知)?

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.

解决方案

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:

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

[...]

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值