1
我想實現對於BB OS 6推送通知和7在我的PhoneGap的應用程序,我已經把credientials/PhoneGap的推notfication,黑莓WebWorks的工作不從黑莓隊第一次給成功收到
後,顯示ERR警報也我可能沒有收到設備上的推送通知。
我使用pushwoosh服務器發送通知,請建議什麼走錯了,這裏是我的代碼
var port = 33981; //THE_PORT_FROM_BB_REGISTRATION;
var serverUrl = "http://pushapi.eval.blackberry.com";
var appId = "4223-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var max = 100;
var wakeUpPage = "index.html";
function openBISPushListener() {
try {
var ops = {port : port, appId : appId, serverUrl : serverUrl, wakeUpPage : wakeUpPage, maxQueueCap : max};
//alert("obj = " + ops.wakeUpPage);
alert(blackberry.push.openBISPushListener(ops, onData, onRegister, onSimChange));
alert("success push");
}
catch (err) {
alert("Called openBISPushListener():Error - " + err);
//alert(err);
}
}
function onRegister(status) {
alert("status" + status);
if (status == 0) {
PushWoosh.register(function(data) {
alert("PushWoosh register success: " + JSON.stringify(data));
}, function(errorregistration) {
alert("Couldn't register with PushWoosh" + errorregistration);
});
}
else if (status == 1) {
alert("push register status network error");
}
else if (status == 2) {
alert("push register status rejected by server");
}
else if (status == 3) {
alert("push register status invalid parameters");
}
else if (status == -1) {
alert("push register status general error");
}
else {
alert("push register status unknown");
}
}
function onData(data) {
alert("Push notifications received. Data is " + blackberry.utils.blobToString(data.payload));
try {
return 0; //indicate acceptance of payload for reliable push
}
catch (err) {
alert("Called onData():Error - " + err);
}
}
function onSimChange() {
//handle Sim Card change
alert("sim changed");
}
您收到了什麼狀態?你應該得到狀態0 – KamalSalem
首先它顯示警報'未定義'的代碼警報(blackberry.push.openBISPushListener(ops,onData,onRegister,onSimChange));它會在alert中顯示'err',然後在關閉應用程序並重新打開時顯示任何內容,然後在打開openBISPushListener()時報警顯示爲錯誤 – Taufik