Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry Push Development

Reply
New Contributor
sobisaldi
Posts: 6
Registered: ‎11-21-2012
My Device: developer and non blackberry user

Implementing push notification feature in blackberry webworks

[ Edited ]

hi all,

 

I am new to blackberry and this is my first post here, so do not know much about community or blackberry 

 

I need to implement push notification feature into my blackberry application I have already registered my application with blackberry and got the registration details 

 

now I found API for implementing this

 

 

here is my code

 

I get the error in this line

 

blackberry.push.openBISPushListener(ops, this.onData,
this.onRegister, this.onSimChange);

 

and the error is

 

result of expression is not an object

 

I have read a lot about blackberry push architecture but could not get proper details 

 

 

 

 

 

var port = '32732';
var serverUrl = 'http://pushapi.eval.blackberry.com';
var appId = '3166-l7370017mR69r753r548MtiMM8279a80472';
var max = 100;
var wakeUpPage = 'index.html';
function openBISPushListener() {
try {
alert("openbispushlistenercalled");
var ops = {
port : port,
appId : appId,
serverUrl : serverUrl,
wakeUpPage : 'wake.html',
maxQueueCap : max
};
alert("call to function");
alert("PORT " + port + " APPID " + appId + " SERVERURL "
+ serverUrl);

 blackberry.push.openBISPushListener(ops, this.onData,
this.onRegister, this.onSimChange);
} catch (err) {
alert(err);
}
}

function onRegister(status) {
if (status == 0) {
alert("success");
} else if (status == 1) {
alert("network error");
} else if (status == 2) {
alert("rejected by server");
} else if (status == 3) {
alert("invalid parameters");
} else if (status == -1) {
alert("general error");
} else {
alert("unknown status");
}
}

function onData(data) {
alert("ondatacalled");
var resultDiv = document.getElementById("resultDiv");
try {
resultDiv.innerHTML += "<br>"
+ blackberry.utils.blobToString(data.payload);
return 0; //indicate acceptance of payload for reliable push
} catch (err) {
alert(err);
}
}

function onSimChange() {
var resultDiv = document.getElementById("resultDiv");
resultDiv.innerHTML += "<br>" + "SIM card is changed!";
}

 

thanks in advance