»   BLACKBERRY »  BlackBerry 5-7 »  HTML5 Webworks

HTML5 Webworks

Html5 webworks has never been so easy! Our extensive guides for all platforms currently available on the market show how to integrate push notifications within several minutes and with several lines of code. You can choose between native programming tools and a diverse set of cross-platform solutions. We are working hard on extending the list of supported SDKs, plugins and modules, so we advise coming back once in a while to see what's new. If you believe that some great tools should be added here, please let us know, and we will do our best to get them up and running!

To integrate Bulkpush into your BlackBerry Phonegap / HTML5 Webworks application you need to do simple following steps:

 

1. Register for Blackberry Push Notifications here: https://www.blackberry.com/profile/?eventId=8121

2. Download bulkpush.js script from https://github.com/Bulkpush/bulkpush-blackberry-sdk/tree/master/Blackberry5-7-HTML and place it in

your project folder. Change the YOUR_BULKPUSH_APP_ID in the script to your Bulkpush Application ID from the control panel.

3. Add the bulkpush script to the index.html file before your master script file. Replace ‘YOUR_BULK_PUSH_APP_ID’  with your Bulkpush Application ID.

 


 
     Bulkpush.appCode = 'YOUR_BULKPUSH_APP_ID';
 

 

4. In your onDeviceReady function add the call to the openBISPushListener() function:

 

function onDeviceReady() {
   //SOME OTHER CODE
   openBISPushListener();
 }

 

5. In your master javascript file add the following code:

 

var port = THE_PORT_FROM_BB_REGISTRATION;
var serverUrl = "http://pushapi.eval.blackberry.com";
var appId = "APP_ID_FROM_BB_REGISTRATION";
var max = 100;
var wakeUpPage = "push.html";
function openBISPushListener() {
    try {
        var ops = {port : port, appId : appId, serverUrl :
  serverUrl, wakeUpPage : wakeUpPage, maxQueueCap : max};
        blackberry.push.openBISPushListener(ops, onData,
         onRegister, onSimChange);
    }
    catch (err) {
        alert(err);
    }   
}
 
function onRegister(status) {
    if (status == 0) {
        Bulkpush.register(function(data) {
           alert("Bulkpush register success: "
           + JSON.stringify(data));
                }, function(errorregistration) {
              alert("Couldn't register with Bulkpush"
           +  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(err);
    }
}
 
function onSimChange() {
    //handle Sim Card change
}

 

That’s it! Easy, isn’t it? You are ready to receive push notifications for your BlackBerry HTML5 Webworks application!

 

For evaluation server in your client app enter: http://pushapi.eval.blackberry.com as a serverUrl (without slash at the end) 
In Bulkpush app configuration enter: https://pushapi.eval.blackberry.com

 

The server sends the notification as JSON payload in the following format:

 

{
  m:'the message itself',
  h: 42, // html page id ex: https://cp.bulkpush.com/content/42
  u: '{key: value}',   //user data
  l: 'http://google.com'   //link to redirect the application to
}

 

© 2015 BulkPush.com By Broadnet Technologies Ltd.