3
回答
ios 多用户推送问题
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   
在给多用户推送信息时,当其中一个用户的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());
			}
		}
举报
suhq24
发帖于5年前 3回/1K+阅
顶部