Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You first need to register for the Blackberry Push service <a href="https://www.blackberry.com/profile/?eventId=8121">here</a></p> <p>They will then send you an email in a couple of days with the app ID, port and push initiator password etc.</p> <p>On the client side you can then listen for push requests:</p> <pre><code>var port = 100; // Change this to the port you received from RIM var appId = "The app ID you received from RIM"; var serverUrl = "http://pushapi.eval.blackberry.com"; var max = 100; var wakeUpPage = "index.html"; function init() { var ops = {port : port, appId : appId, serverUrl : serverUrl, wakeUpPage : wakeUpPage, maxQueueCap : max}; blackberry.push.openBISPushListener(ops, pushReceive, pushRegister, simChange); } function pushReceive(data) { try { var message = blackberry.utils.blobToString(data.payload); return 0; } catch(err) { } } function pushRegister(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"); } } window.onload = function() { init(); } </code></pre> <p>Also make sure you have <code>&lt;feature id="blackberry.push" /&gt;</code> and <code>&lt;feature id="blackberry.utils" /&gt;</code> in your config.xml.</p> <p>What I also noted was that when the app is closed the pushReceive() doesn't get called. You can bypass this by running the app in the background: </p> <pre><code>function handleExit() { blackberry.app.requestBackground(); } blackberry.app.event.onExit(handleExit); </code></pre> <p>and use <code>blackberry.app.requestForeground();</code> to bring app to the front.</p> <p>The other thing which took me a while to figure out was that it might take a while before pushRegister() is called (this registers the PIN on BIS). So make sure this gets called otherwise you will never be able to receive push messages.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload