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
Highlighted
Trusted Contributor
Posts: 152
Registered: ‎02-12-2011
My Device: Not Specified

Reading PUSH BIS Notification

I'm trying to implement push notification on my application using BIS service. 

 

I have the following code in the background start page of my application

 

function openBISPushListener(){
try {
var ops = {
port: port,
appId: appId,
serverUrl: serverUrl,
wakeUpPage: wakeUpPage,
maxQueueCap: max
};
blackberry.push.openBISPushListener(ops, onData, onRegister, onSimChange);
}
catch (err) {
navigator.notification.vibrate(1000);
}
}

function onRegister(status){
if (status == 0) {
navigator.notification.beep(1);
}
else
if (status == 1) {
navigator.notification.beep(5);
navigator.notification.vibrate(1000);
}
else
if (status == 2) {
navigator.notification.beep(6);
}
else
if (status == 3) {
navigator.notification.beep(7);
}
else
if (status == -1) {
navigator.notification.beep(8);
}
else {
navigator.notification.beep(9);
}
}

function onData(data){
// var resultDiv = document.getElementById("resultDiv");
try {
// resultDiv.innerHTML += "<br>" + blackberry.utils.blobToString(data.payload);
var n = blackberry.utils.blobToString(data.payload);
var amt = isNaN(n) ? 1 : parseInt(n);
navigator.notification.beep(1);
blackberry.app.showBannerIndicator("indicator.png", amt);
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!";
}

var port = 00000; //masked
var serverUrl = "http://pushapi.eval.blackberry.com";
var appId = xxxxx; //masked
var max = 100;
var wakeUpPage = "index.html"; // main  page

 

Now on installation It will successfully register the app to listen and I will successfully recieve a push notification. In opening the app and reading the notification I have a the code

 

blackberry.app.event.onExit(function(){ alert('ok');
openBISPushListener();
});

 

Which would supposedly re-register the listener on exiting the application.

 

However, in pushing out subsequent BIS messages via the server implementation I am unable to recieve any of them on the client.

 

 

What am I doing wrong here....?