黑莓推送客户端应用程序黑莓注册失败

时间:2012-11-02 06:04:35

标签: blackberry blackberry-jde blackberry-push

我是黑莓应用程序开发的新手,我需要创建一个可以接收推送通知的应用程序。

我创建了该应用程序,并尝试使用xtify将通知推送到设备。

我已经注册了rim以进行推送评估,并获得了诸如网址,应用ID,密码等凭据。

当应用程序启动时,我创建一个新线程来执行推送注册过程。 我尝试向推送评估网址发送http Get请求以注册设备。当我尝试打开连接时,我收到io异常,无效的url参数。

我在设备中使用wifi连接进行网络连接。我没有设备中的SIM卡。 网址是

http://cpXXX.pushapi.eval.blackberry.com/mss/PD_subReg?serviceid='My Application Id'&osversion='My OS Version'&model='Device Model';deviceside=false;ConnectionType=mds-public

以下是我用来发送请求的代码。

    DataBuffer buffer = new DataBuffer(256, false);
    httpUrl = "http://cpXXX.pushapi.eval.blackberry.com/mss/PD_subReg?serviceid='My Application Id'&osversion='My OS Version'&model='Device Model';deviceside=false;ConnectionType=mds-public"

    InputStream inputStream = null;
    Connection conn = null;
    HttpConnection httpConn = null;
    try {
        httpUrl ;
        conn = Connector.open(httpUrl);
        if (conn instanceof HttpConnection) {
            httpConn = (HttpConnection) conn;
            int responseCode = httpConn.getResponseCode();
            if(responseCode == 200){
                inputStream = httpConn.openInputStream();
                int length = inputStream.read(buffer.getArray());
                buffer.setLength(length);
                String response = new String( buffer.getArray(), buffer.getArrayStart(), buffer.getArrayLength() );
                return response;
            }else { 
                throw new IOException( "Http error: " + responseCode);
            }
        }

        else {
            throw new IOException("Can not make HTTP connection for URL '"
                    + httpUrl + "'");
        }

    }
    finally {
        if (httpConn != null) {
            try {
                httpConn.close();
            } catch (IOException e) {
                System.out.println(e.getMessage());
                e.printStackTrace();
            }
        }
        close(conn, inputStream, null);
    }

请帮帮我。我在等待回复。我已经坚持了几天。请指教。任何人都知道我在哪里可以获得设备注册api的文档?

1 个答案:

答案 0 :(得分:0)

Thanx对@Black Pearl的建议,我能够解决这个问题。为了使黑莓注册工作,您需要一个有效的BIS连接。我一直在尝试使用wifi连接,因此无法正常工作。