简体   繁体   中英

100% CPU used in javapns

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());
    }

What version?

Version 2 just came out, and fixed a number of issues.

It is also much easier to implement.

我在javapns错误列表中找到了解决方案,另请参见: javapns issue48 ,它修复了HTTP代理错误,并且在我发送通知消息时不会导致100%cpu。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM