HTML5 / Webworks

HTML5 / Webworks 2.0 Integration Guide

Download Script
Download Sample

Here are a few simple steps to integrate Pushwoosh plugin into your BlackBerry 10 Webworks 2.0 application:

1. Add the following list of plugins into your project:

com.blackberry.app
com.blackberry.identity
com.blackberry.invoked
com.blackberry.notification
com.blackberry.push
com.blackberry.ui.dialog
com.blackberry.utils

2. Add the http://cp.pushwoosh.com access url into your config.xml:

<access uri="http://cp.pushwoosh.com" subdomains="true" />

3. Add the following script to config.xml:

<rim:invoke-target id="GENERATE.invoke.push">
    <type>APPLICATION</type>
    <filter>
        <action>bb.action.PUSH</action>
        <mime-type>application/vnd.push</mime-type>
    </filter>
</rim:invoke-target>
 
<rim:invoke-target id="GENERATE.invoke.open">   // GENERATE is the unique identification value of your application 
    <type>APPLICATION</type>
    <filter>
        <action>bb.action.OPEN</action>
        <mime-type>text/plain</mime-type>
    </filter>
</rim:invoke-target>

In the code above replace “GENERATE” with a unique identification value of the app.

4. Add the following permissions:

<rim:permissions>
    <rim:permit>read_device_identifying_information</rim:permit>
    <rim:permit system="true">_sys_use_consumer_push</rim:permit>
    <rim:permit>run_when_backgrounded</rim:permit>
    <rim:permit>post_notification</rim:permit>
</rim:permissions>

5. Add the following libraries to your project:

Download our plugin (pushwoosh.js) here and place it in “js” subfolder (ex: “js/pushwoosh.js”).

Download jQuery library and place it in “js” subfolder (ex: “js/jquery-1.10.2.min.js”).

6. Add the following script to the index.html:

<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/pushwoosh.js"></script>
<script type="text/javascript">
    document.addEventListener('deviceready', function ondeviceready() {                 
        pushwoosh.register(function(pushObject){
            //This is a push handler function! Let's show alert with push content!
            alert("push: " + JSON.stringify(pushObject));
        });     
    }, false);
</script>

NOTE:

  • We recommend adding this script inside the body tag in the very end;
  • You can use different jQuery libraries, download them here;
  • Don't bother looking for cordova.js – the web worker builder will do everything.

7. Change the following application settings in pushwoosh.js with settings you receive from BlackBerry:

var config = {
    ops : {
        invokeTargetId : "GENERATE.invoke.push", // use the same id value as in config.xml
        appId : "XXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", // AppId from the Blackberry configuration email 
        ppgUrl : "http://cpXXXX.pushapi.eval.blackberry.com" // ppgUrl from the BlackBerry configuration email 
    },
    pushwooshAppId : "XXXXX-XXXXX", // Pushwoosh Application Code
    invokeTargetIdOpen : "GENERATE.invoke.open" // use the same id value as in config.xml
};

Make sure PGG Url is HTTP.

HTTPS push notifications channel won’t be able to subscribe.

HTML5 / Webworks

HTML5 / Webworks 2.0 Integration Guide