求大神给我看一下ios推送的问题

qq1018789167 2014-08-21 01:31:17
代码
package com.vo;

import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;

import com.entity.ReturnStatusChinese;
import com.util.BeanUtil;
import com.util.StringUtil;

import javapns.back.PushNotificationManager;
import javapns.back.SSLConnectionHelper;
import javapns.data.Device;
import javapns.data.PayLoad;
@Service
@RemotingDestination(channels = { "my-amf" })
public class IosPush {

public static void main(String[] args) throws Exception {
try {
String deviceToken = "7be3700ab49f705d182548cb0d6d3ae880dd4de82bc30aaebe2a4148680b0f28";//iphone手机获取的token

PayLoad payLoad = new PayLoad();
payLoad.addAlert("我的push测试");//push的内容
payLoad.addBadge(1);//图标小红圈的数值
payLoad.addSound("default");//铃音

PushNotificationManager pushManager = PushNotificationManager.getInstance();
pushManager.addDevice("iPhone", deviceToken);

//Connect to APNs
/************************************************
测试的服务器地址:gateway.sandbox.push.apple.com /端口2195
产品推送服务器地址:gateway.push.apple.com / 2195
***************************************************/
String host= "gateway.sandbox.push.apple.com";
int port = 2195;
String certificatePath= "/Users/jcjc/Desktop/push_p.p12";//导出的证书
String certificatePassword= "sunlg";//此处注意导出的证书密码不能为空因为空密码会报错
pushManager.initializeConnection(host,port, certificatePath,certificatePassword, SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);

//Send Push
Device client = pushManager.getDevice("iPhone");
pushManager.sendNotification(client, payLoad);
pushManager.stopConnection();

pushManager.removeDevice("iPhone");
}
catch (Exception e) {
e.printStackTrace();
}

}
}

错误信息
java.lang.RuntimeException: Stub!
at org.json.JSONObject.<init>(JSONObject.java:4)
at javapns.data.PayLoad.<init>(Unknown Source)
at com.vo.IosPush.main(IosPush.java:22)


不知道是啥原因求大神
...全文
212 10 打赏 收藏 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
rumlee 2014-08-21
  • 打赏
  • 举报
回复
其实你可以使用极光推送jpush,简单多了。而且ios和安卓可以通用。
致知Fighting 2014-08-21
  • 打赏
  • 举报
回复
PayLoad的构造方法里抛出的异常,你检查一下PayLoad里到底干了些什么,反编译看看。
qq1018789167 2014-08-21
  • 打赏
  • 举报
回复
引用 6 楼 fangmingshijie 的回复:
你参数传的不对。给你个链接自己看看。
我照着您给的链接还是错啊
qq1018789167 2014-08-21
  • 打赏
  • 举报
回复
引用 6 楼 fangmingshijie 的回复:
你参数传的不对。给你个链接自己看看。
哦哦谢谢;啊
  • 打赏
  • 举报
回复
你参数传的不对。给你个链接自己看看。
qq1018789167 2014-08-21
  • 打赏
  • 举报
回复
引用 3 楼 fangmingshijie 的回复:
pushManager.sendNotification(client, payLoad); 这两个参数是不是颠倒了。
大神,没颠倒。。倒过来编译都不通过啦
qq1018789167 2014-08-21
  • 打赏
  • 举报
回复
引用 3 楼 fangmingshijie 的回复:
pushManager.sendNotification(client, payLoad); 这两个参数是不是颠倒了。
是吗。我试下哈..
  • 打赏
  • 举报
回复
pushManager.sendNotification(client, payLoad); 这两个参数是不是颠倒了。
qq1018789167 2014-08-21
  • 打赏
  • 举报
回复
引用 1 楼 ygycomon 的回复:
json数据的格式不对吧,把json数据打印出来看看
json 是那个token吗
致知Fighting 2014-08-21
  • 打赏
  • 举报
回复
json数据的格式不对吧,把json数据打印出来看看

62,620

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧