我正在为项目发送通知给iPhone。我用javapns。但是当我invork消息:javapns中使用的CPU 100%
pushManager.sendNotification(client, complexPayLoad);
我发现邮件无法正确地返回,并导致CPU使用率达到100%。 有人可以告诉我哪里错了我的代码?谢谢。
更completement代码
try {
// create a complex PayLoad with a custom alert
PayLoad complexPayLoad = new PayLoad();
PayLoadCustomAlert customAlert = new PayLoadCustomAlert();
customAlert.addBody(message);
complexPayLoad.addCustomAlert(customAlert);
complexPayLoad.addSound("chime");
for (String key : new HashSet<String>(data.keySet())) {
complexPayLoad.addCustomDictionary(key, (String)data.get(key));
}
try {
// Link iPhone's UDID (64-char device token) to a stringName
pushManager.addDevice(token, token);
} catch (Exception ex) {
// Perhaps we added duplicate devices
log.debug("Perhaps we added duplicate devices");
}
// Get iPhone client
Device client = pushManager.getDevice(token);
// Send message
pushManager.sendNotification(client, complexPayLoad);
log.info("Message sent!"); // i cannot get this message
} catch (Exception e) {
log.error(e.getMessage());
}
我检查javapns的源代码。我发现我在sendNotification方法中挂在这里:'logger.debug(“Notification sent”); logger.debug(“In:[”+ in.readLine()+“]”); while(!this.socket.isInputShutdown()){while(in.ready()){logger.debug(“ready now”); logger.debug(in.readLine()); System.out.println(this.socket.getInputStream()。read()); }}' – Apollo