{"_id":"55ae10e38576b92300291c64","category":{"_id":"5540e5febb9e762d00f594d3","pages":["55ae0e64f302af23000ac07b","55ae10e38576b92300291c64"],"version":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","__v":2,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-29T14:09:02.921Z","from_sync":false,"order":5,"slug":"blackberry-5-7","title":"BlackBerry 5-7"},"parentDoc":null,"project":"5540ce1b31827a0d007ab1cc","user":"55a79a4d4a33f92b00b7a111","__v":7,"version":{"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","__v":31,"createdAt":"2015-04-29T12:27:08.390Z","releaseDate":"2015-04-29T12:27:08.390Z","categories":["5540ce1c31827a0d007ab1d0","5540d91bbb9e762d00f594ad","5540e5f131827a0d007ab212","5540e5febb9e762d00f594d3","5540e61331827a0d007ab213","5540e6195cf9682100d61afa","5540e62631827a0d007ab214","5540e63031827a0d007ab215","5540e63531827a0d007ab216","5540e63e5cf9682100d61afc","5540e6445cf9682100d61afd","5540e64a5cf9682100d61afe","55a4ff5b2e70c0250038050f","55acb28318eefd0d0071d504","55ae1abe8576b92300291c80","55ae453ef302af23000ac109","55af586d555b900d0036d296","55af91dac8a85321007a53c3","55b9fee204775a2f00628071","55b9ff0e04775a2f00628072","55b9ff4604775a2f00628073","55b9ff5fd72d1e1900276a38","55b9ff7f04775a2f00628074","55b9ff90eb08801900f833e5","55b9ffa5d72d1e1900276a39","55b9ffca04775a2f00628075","55b9fffdd72d1e1900276a3a","56bc2f033ee9e70d008b46af","56c2f6efbbf9ec2d00e0fe4f","57595bbb18760817001e8bbe","57d8d9793916800e003dde53"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["5854169cf655251b00302e9e"],"next":{"pages":[],"description":""},"createdAt":"2015-07-21T09:29:07.296Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"[**Download Script**](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/Blackberry5-7-HTML)\n[**Sample Project**](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/Samples/Blackberry-HTML5-Webworks)\n\nIntegrating Pushwoosh into your BlackBerry Phonegap / HTML5 Webworks app is quick and easy! Just do the following steps:\n\n**1.** Register for Blackberry Push Notifications here: https://www.blackberry.com/profile/?eventId=8121\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Enter: `http://pushapi.eval.blackberry.com` as serverUrl of evaluation server in your client app (no slash at the end!) \\nIn Pushwoosh app config enter: `https://pushapi.eval.blackberry.com`\"\n}\n[/block]\n**2.** Download [pushwoosh.js](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/blob/master/Blackberry5-7-HTML/pushwoosh.js) script from https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/Blackberry5-7-HTML and place it in your project folder. Change YOUR_PUSHWOOSH_APP_ID in your Pushwoosh Application ID script from the control panel.\n\n**3.** Add the pushwoosh script to index.html before your master script file. Replace **‘YOUR_PUSHWOOSH_APP_ID’** with your Pushwoosh Application ID. You will also need jquery.js. For example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<script src=\\\"http://code.jquery.com/jquery-1.8.2.min.js\\\" type=\\\"text/javascript\\\"></script>\\n<script src=\\\"pushwoosh.js\\\" type=\\\"text/javascript\\\"></script>\\nPushWoosh.appCode = 'YOUR_PUSHWOOSH_APP_ID';\\n \\n<script src=\\\"master.js\\\" type=\\\"text/javascript\\\"></script>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\n**4.** In your onDeviceReady function add the call to openBISPushListener():\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"function onDeviceReady() {\\n    //OTHER CODE\\n    openBISPushListener();\\n}\\n\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**5.** In your master javascript file add the following code:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var port = THE_PORT_FROM_BB_REGISTRATION;\\nvar serverUrl = \\\"http://pushapi.eval.blackberry.com\\\";\\nvar appId = \\\"APP_ID_FROM_BB_REGISTRATION\\\";\\nvar max = 100;\\nvar wakeUpPage = \\\"push.html\\\";\\nfunction openBISPushListener() {\\n    try {\\n        var ops = {port : port, appId : appId, serverUrl : serverUrl, wakeUpPage : wakeUpPage, maxQueueCap : max};\\n        blackberry.push.openBISPushListener(ops, onData, onRegister, onSimChange);\\n    }\\n    catch (err) {\\n        alert(err);\\n    }     \\n} \\n \\nfunction onRegister(status) {\\n    if (status == 0) {\\n        PushWoosh.register(function(data) {\\n                    alert(\\\"PushWoosh register success: \\\" + JSON.stringify(data));\\n                }, function(errorregistration) {\\n                    alert(\\\"Couldn't register with PushWoosh\\\" +  errorregistration);\\n                });     \\n    }\\n    else if (status == 1) {\\n        alert(\\\"push register status network error\\\");\\n    }\\n    else if (status == 2) {\\n        alert(\\\"push register status rejected by server\\\");\\n    }\\n    else if (status == 3) {\\n        alert(\\\"push register status invalid parameters\\\");\\n    }\\n    else if (status == -1) {\\n        alert(\\\"push register status general error\\\");\\n    }\\n    else {\\n        alert(\\\"push register status unknown\\\");\\n    }\\n}\\n     \\nfunction onData(data) {\\n    alert(\\\"Push notifications received. Data is \\\" + blackberry.utils.blobToString(data.payload));\\n    try {\\n        return 0; //indicate acceptance of payload for reliable push\\n    } \\n    catch (err) {\\n        alert(err);\\n    }\\n}\\n \\nfunction onSimChange() {\\n    //handle Sim Card change\\n}\\n\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThat’s it! You are ready to receive push notifications for your BlackBerry HTML5 Webworks application!\n\nThe server sends notifications as JSON payload in the following format:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n   m:'the message itself',\\n   h: 42, // html page id ex: https://cp.pushwoosh.com/content/42\\n   u: '{key: value}',   //user data\\n   l: 'http://google.com'   //app redirect link\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","excerpt":"HTML 5 / Webworks Integration Guide","slug":"html5-webworks","type":"basic","title":"HTML5 Webworks"}

HTML5 Webworks

HTML 5 / Webworks Integration Guide

[**Download Script**](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/Blackberry5-7-HTML) [**Sample Project**](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/Samples/Blackberry-HTML5-Webworks) Integrating Pushwoosh into your BlackBerry Phonegap / HTML5 Webworks app is quick and easy! Just do the following steps: **1.** Register for Blackberry Push Notifications here: https://www.blackberry.com/profile/?eventId=8121 [block:callout] { "type": "info", "body": "Enter: `http://pushapi.eval.blackberry.com` as serverUrl of evaluation server in your client app (no slash at the end!) \nIn Pushwoosh app config enter: `https://pushapi.eval.blackberry.com`" } [/block] **2.** Download [pushwoosh.js](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/blob/master/Blackberry5-7-HTML/pushwoosh.js) script from https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/Blackberry5-7-HTML and place it in your project folder. Change YOUR_PUSHWOOSH_APP_ID in your Pushwoosh Application ID script from the control panel. **3.** Add the pushwoosh script to index.html before your master script file. Replace **‘YOUR_PUSHWOOSH_APP_ID’** with your Pushwoosh Application ID. You will also need jquery.js. For example: [block:code] { "codes": [ { "code": "<script src=\"http://code.jquery.com/jquery-1.8.2.min.js\" type=\"text/javascript\"></script>\n<script src=\"pushwoosh.js\" type=\"text/javascript\"></script>\nPushWoosh.appCode = 'YOUR_PUSHWOOSH_APP_ID';\n \n<script src=\"master.js\" type=\"text/javascript\"></script>", "language": "html" } ] } [/block] **4.** In your onDeviceReady function add the call to openBISPushListener(): [block:code] { "codes": [ { "code": "function onDeviceReady() {\n //OTHER CODE\n openBISPushListener();\n}\n", "language": "javascript" } ] } [/block] **5.** In your master javascript file add the following code: [block:code] { "codes": [ { "code": "var port = THE_PORT_FROM_BB_REGISTRATION;\nvar serverUrl = \"http://pushapi.eval.blackberry.com\";\nvar appId = \"APP_ID_FROM_BB_REGISTRATION\";\nvar max = 100;\nvar wakeUpPage = \"push.html\";\nfunction openBISPushListener() {\n try {\n var ops = {port : port, appId : appId, serverUrl : serverUrl, wakeUpPage : wakeUpPage, maxQueueCap : max};\n blackberry.push.openBISPushListener(ops, onData, onRegister, onSimChange);\n }\n catch (err) {\n alert(err);\n } \n} \n \nfunction onRegister(status) {\n if (status == 0) {\n PushWoosh.register(function(data) {\n alert(\"PushWoosh register success: \" + JSON.stringify(data));\n }, function(errorregistration) {\n alert(\"Couldn't register with PushWoosh\" + errorregistration);\n }); \n }\n else if (status == 1) {\n alert(\"push register status network error\");\n }\n else if (status == 2) {\n alert(\"push register status rejected by server\");\n }\n else if (status == 3) {\n alert(\"push register status invalid parameters\");\n }\n else if (status == -1) {\n alert(\"push register status general error\");\n }\n else {\n alert(\"push register status unknown\");\n }\n}\n \nfunction onData(data) {\n alert(\"Push notifications received. Data is \" + blackberry.utils.blobToString(data.payload));\n try {\n return 0; //indicate acceptance of payload for reliable push\n } \n catch (err) {\n alert(err);\n }\n}\n \nfunction onSimChange() {\n //handle Sim Card change\n}\n", "language": "javascript" } ] } [/block] That’s it! You are ready to receive push notifications for your BlackBerry HTML5 Webworks application! The server sends notifications as JSON payload in the following format: [block:code] { "codes": [ { "code": "{\n m:'the message itself',\n h: 42, // html page id ex: https://cp.pushwoosh.com/content/42\n u: '{key: value}', //user data\n l: 'http://google.com' //app redirect link\n}", "language": "json" } ] } [/block]