Blackberry push


There are two kinds of blackberry push: RIM push and PAP push. You need MDS server to simulate your push application using Blackberry simulator.
This code is a sample of Blackberry push enabled with Webworks environment:

 

<!DOCTYPE HTML PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”>
<html>
<head>
<h5>sample push application by pujie:abunajiyah.wordpress.com</h5>
<script type=”text/javascript”>
var port = 100;
function subscribe() {
blackberry.push.openPushListener(function(data) {
if (data != null) {
var text = blackberry.utils.blobToString(data.payload);
alert(“You have a push message:” + text );
} else {
alert(“no data from push”);
}
}, port);
alert(“push Listening has just started”);
}
function unsubscribe() {
blackberry.push.closePushListener(port);
alert(“Push listening has stopped”);
}
</script>
<meta name=”viewport” id=”viewport” content=”initial-scale=1.0,user-scalable=no” />
<title>Job Seeker</title>
</head>
<body>
<button id=”btnsubscribe” onclick=”subscribe()”>Subscribe</button>
<button id=”btnunsubscribe” onclick=”unsubscribe()”>Un Subscribe</button>
</body>
</html>

In your config.xml , add these features in your widget permission: blackberry.push, blackberry.system, blackberry.utils

About abunajiyah
A Programmer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: