ios 多用户推送问题

suhq24 发布于 2013/03/08 14:04
阅读 1K+
收藏 0
在给多用户推送信息时,当其中一个用户的token有误时,在他之后的用户就无法收到推送信息,何解?
public static void pushToClients(String filePath,String password,String content,List<PushInfo> pushInfos) {
			System.out.println("to pushs");
			try {
				PayLoad payLoad=new PayLoad();
				payLoad.addAlert(content);
				payLoad.addBadge(1);//应用图标上小红圈上的数值     //
				payLoad.addSound("default");
				
				PushNotificationManager pushManager=PushNotificationManager.getInstance();
				
				//链接到APNs  
			    pushManager.initializeConnection("gateway.push.apple.com", 2195, 
			    		filePath, password, SSLConnectionHelper.KEYSTORE_TYPE_PKCS12); 
			    
			    for (int i = 0; i < pushInfos.size(); i++) {System.out.println("iphone" + pushInfos.get(i).getId());
			    	pushManager.addDevice("iphone" + pushInfos.get(i).getId(), pushInfos.get(i).getToken());  
			        Device client = pushManager.getDevice("iphone"+ pushInfos.get(i).getId());  
			        pushManager.sendNotification(client, payLoad);  
				}
			    
			    pushManager.stopConnection();  
			    for (int i = 0; i < pushInfos.size(); i++) {  
			    	pushManager.removeDevice("iphone" + pushInfos.get(i).getId());
			    }
			    
			} catch (Exception e) {
				// TODO: handle exception
				System.out.println(e.getMessage());
			}
		}
加载中
0
hanzhankang
hanzhankang
try...catch 的问题吧
0
echodjb
echodjb
看你代码怎么写了  你是不是遇到错误就队列终止呢
0
牧龙
牧龙
一是向苹果的服务推送消息时,如果遇到无效的deviceToken,苹果会断开网络连接,而JavaPNS不会进行重连。苹果原文:
    If you send a notification and APNs finds the notification malformed or otherwise unintelligible, it returns an error-response packet prior to disconnecting. (If there is no error, APNs doesn’t return anything.) Figure 5-3 depicts the format of the error-response packet.
返回顶部
顶部