javapns 中 CPU 使用率 100%
我正在从事一个向 iPhone 发送通知的项目。我用的是javapns。但是当我调用该消息时:
pushManager.sendNotification(client, complexPayLoad);
我发现该消息无法正确返回,并且导致CPU使用率变为100%。 谁能告诉我我的代码哪里出了问题?谢谢。
更多完整代码
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());
}
i'm working for a project send notification to iPhone. and i used javapns. but when i invork the message:
pushManager.sendNotification(client, complexPayLoad);
i found the message cannot return correctly, and it cause cpu usage become 100%.
could anybody tell me where's wrong about my code? Thanks.
more completement code
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());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
什么版本?
版本 2 刚刚发布,修复了一些问题。
它也更容易实施。
What version?
Version 2 just came out, and fixed a number of issues.
It is also much easier to implement.