由于某种原因,当我尝试在黑莓曲线上注册推送服务时,我不断收到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 :(得分: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