2011-04-01 104 views
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任何回应。

回答

0

PushApplicationStatus.getStatus()返回STATUS_PENDING,STATUS_ACTIVE,STATUS_FAILED或STATUS_NOT_REGISTERED中的一个。

我不认为你应该比较这个状态值与任何REASON_ *常量。

此外,如果状态是STATUS_NOT_REGISTERED,那么你应该尝试注册你的应用程序!您的代码在else分支中执行注册,因为四个STATUS_ *值中的一个应该匹配,所以该代码不应该到达。

查看BlackBerry Push Service SDK附带的启用了示例推送的应用程序。您可以在jar文件中找到完整的源代码:sample-push-enabled-app-1.0.1.11-sources.jar