黑莓推送通知 - 未在设备上接收

时间:2013-05-18 06:43:45

标签: java blackberry push-notification blackberry-simulator blackberry-jde

自从过去几天以来,我一直在努力在设备上收到消息。最后我想从专家那里得到帮助。

以下是我遵循的步骤。

  1. 我在核心java中创建了Push initiator。 注意:我收到响应代码:200 OK - 我假设此消息到达PPG进行进一步处理 - 但未确认。

  2. 我使用了Blackberry Device的Push Enabled应用程序示例 - 我能够在特定端口上注册和等待消息。但我没有收到任何消息:(

  3. 现在我很无奈,我的问题是 1.我是否在正确的轨道上 2.有没有办法找出如何调试以及我的消息挂起的地方。

    我正在等待一些积极的解决方案。提前谢谢..

    这是我用于J2SE的Push initiator的实际代码

    StringBuffer dataToSend = new StringBuffer();
        dataToSend.append("--" + BOUNDARY);
        dataToSend.append(" ");
        dataToSend.append("Content-Type: application/xml; charset=UTF-8");
        dataToSend.append(" ");
        dataToSend.append("<?xml version=\"1.0\"?>");
        dataToSend
                .append("<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 2.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd\" [<?wap-pap-ver supported-versions=\"2.0\"?>]>");
        dataToSend.append("<pap>");
        String myPushId = ""+ new Random().nextInt();
        dataToSend.append("<push-message push-id=\"" + myPushId
                + "\" source-reference=\"" + applicationID + "\">");
        dataToSend.append("<address address-value=\"" + pin + "\"/>");
        dataToSend
                .append("<quality-of-service delivery-method=\"confirmed\"/>");
        dataToSend.append("</push-message>");
        dataToSend.append("</pap> ");
        dataToSend.append("--" + BOUNDARY);
        dataToSend.append(" Content-Encoding: binary ");
        dataToSend.append(" Content-Type: text/plain ");
        dataToSend.append(" ");
        dataToSend.append("X-Wap-Application-Id: " + applicationID);
        dataToSend.append(" X-Rim-Push-Type: browser-channel  X-Rim-Push-Title: Test X-Rim-Push-Unread-Icon: http://rim.com/icon_new.png ");
        dataToSend.append("X-Rim-Push-Read-Icon: http://rim.com/icon_viewed.png  ");
                dataToSend.append("X-Rim-Delete-URL: http://rim.com/ReceiveDelete ");
                        dataToSend.append("X-Rim-Transcode-Content: */* ");
                        dataToSend.append("Cache-Control: max-age=3600 ");
        dataToSend.append(msg);
        dataToSend.append("--" + BOUNDARY + "--");
        dataToSend.append(" ");
         printer(dataToSend.toString());
        // printer("-------------------------------------------------------------------");
        String authInfo = applicationID + ":" + userPW;
    
        String encoding = new sun.misc.BASE64Encoder().encode(authInfo
                .getBytes());
        // authInfo = Base64.encode(authInfo.getBytes());
        authInfo = "Basic " + encoding;
        printer(authInfo);
        URL url;
        HttpURLConnection connection = null;
        try {
            // Create connection
            url = new URL(targetURL);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type",
                    "multipart/related; boundary=" + BOUNDARY
                            + "; type=application/xml");
            connection.setRequestProperty("User-Agent",
                    "BlackBerry Push Service SDK/1.0");
            // / connection.setRequestProperty("Authorization",
            // authInfo.getBytes().toString());
            connection.setRequestProperty("Authorization", authInfo);
    
            connection.setRequestProperty("Accept",
                    "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2");
            connection.setRequestProperty("Connection", "keep-alive");
            connection.setRequestProperty("Content-Length",
                    "" + dataToSend.length());
            connection.setDoInput(true);
            connection.setDoOutput(true);
    
            // Send request
            DataOutputStream wr = new DataOutputStream(
                    connection.getOutputStream());
            wr.writeBytes(dataToSend.toString());
            wr.flush();
            wr.close();
    
            printer("" + connection.getResponseCode());
            String response = connection.getResponseMessage();
    
            printer(response);
            // return response;
    

0 个答案:

没有答案