0

出于某种原因,当我尝试在黑莓曲线上注册推送服务时,我不断收到 PushApplicationStatus.STATUS_NOT_REGISTERED。它在火炬,风暴上效果很好,但在粗体和曲线上有很多问题。

这是我如何注册推送服务的代码:

int port = Constant.Net.PUSH_PORT;
    String appId = Constant.Net.APP_PUSH_ID;
    String bpasUrl = Constant.Net.BPAS_URL;
    ApplicationDescriptor ad = ApplicationDescriptor.currentApplicationDescriptor();
    byte serverType = PushApplicationDescriptor.SERVER_TYPE_BPAS;

    PushApplicationDescriptor pad = new PushApplicationDescriptor(appId, port, bpasUrl, serverType, ad);
    PushApplicationStatus status = PushApplicationRegistry.getStatus(pad);
    byte bstatus = status.getStatus();

    if (bstatus == PushApplicationStatus.STATUS_ACTIVE)
    {
        L.devout("BpasProtocol: already registered");
        AlertDialog.alert(LH.getString(LH.LBL_PUSH_REGISTERED));
        return;
    }
    else if (bstatus == PushApplicationStatus.STATUS_PENDING)
    {
        L.devout("BpasProtocol: status pending");
        AlertDialog.alert(LH.getString(LH.LBL_PUSH_REGISTERED));
        return;
    }
    else if (bstatus == PushApplicationStatus.REASON_REJECTED_BY_SERVER )
    {
        L.devout("BpasProtocol: rejected by server");
        AlertDialog.alert("REASON_REJECTED_BY_SERVER");
        return;
    }
    else if (bstatus == PushApplicationStatus.REASON_INVALID_PARAMETERS )
    {
        L.devout("BpasProtocol: REASON_INVALID_PARAMETERS");
        AlertDialog.alert("REASON_INVALID_PARAMETERS");
        return;
    }
    else if (bstatus == PushApplicationStatus.REASON_SIM_CHANGE )
    {
        L.devout("BpasProtocol: REASON_SIM_CHANGE");
        AlertDialog.alert("REASON_SIM_CHANGE");
        return;
    }
    else if (bstatus == PushApplicationStatus.REASON_NETWORK_ERROR )
    {
        L.devout("BpasProtocol: REASON_NETWORK_ERROR");
        AlertDialog.alert("REASON_NETWORK_ERROR");
        return;
    }
    else if (bstatus == PushApplicationStatus.REASON_API_CALL )
    {
        L.devout("BpasProtocol: REASON_API_CALL");
        AlertDialog.alert("REASON_API_CALL");
        return;
    }
    else if (bstatus == PushApplicationStatus.STATUS_NOT_REGISTERED )
    {
        L.devout("BpasProtocol: Status not registered");
        AlertDialog.alert("STATUS_NOT_REGISTERED");

        return;
    }
    else if (bstatus == PushApplicationStatus.STATUS_FAILED )
    {
        L.devout("BpasProtocol: Status failed");
        return;
    }
    else
    {
        L.devout("BpasProtocol: scheduling registration");

        PushApplicationRegistry.registerApplication(pad);
        AlertDialog.alert(LH.getString(LH.LBL_PUSH_REGISTERED));
    }

任何帮助将不胜感激,因为从 RIM 获得任何响应都需要很长时间。

4

1 回答 1

0

PushApplicationStatus.getStatus() 返回 STATUS_PENDING、STATUS_ACTIVE、STATUS_FAILED 或 STATUS_NOT_REGISTERED 之一。

我认为您不应将此状态值与任何 REASON_* 常量进行比较。

此外,如果状态为 STATUS_NOT_REGISTERED 那么您应该尝试注册您的应用程序!您的代码在 else-branch 中进行注册,因为四个 STATUS_* 值之一应该匹配,所以永远不会到达。

查看 BlackBerry Push Service SDK 附带的 sample-push-enabled-app。您将在 jar 文件中找到完整的源代码:sample-push-enabled-app-1.0.1.11-sources.jar

于 2011-06-16T09:05:02.803 回答