我正在爲項目發送通知給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