{"_id":"55ae2eda8576b92300291caf","user":"55a79a4d4a33f92b00b7a111","parentDoc":null,"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"},"__v":6,"category":{"_id":"55ae1abe8576b92300291c80","project":"5540ce1b31827a0d007ab1cc","pages":["55ae1b43f302af23000ac0ab","55ae240f2723e51900898f96","55ae2c822723e51900898fa2","55ae2eda8576b92300291caf"],"version":"5540ce1c31827a0d007ab1cf","__v":4,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-21T10:11:10.515Z","from_sync":false,"order":6,"slug":"blackberry-10","title":"BlackBerry 10"},"project":"5540ce1b31827a0d007ab1cc","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-07-21T11:36:58.743Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"[**Download SDK**](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/BlackBerry10-Cascades)\n[**Download Sample**](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/Samples/Blackberry-Cascades)\n\nSDK contains the source code for BlackBerry 10 Cascades platform. [download](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/BlackBerry10-Cascades) it from our repo first.\n\nList the libraries to be defined in the **.pro** file to avoid compilation error:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"LIBS += -lbb\\nLIBS += -lbbdevice\\nLIBS += -lbbsystem\\nLIBS += -lbbnetwork\\nLIBS += -lbbplatform\\nLIBS += -lbbdata\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"IMPORTANT: For push evaluation the PPG_URL should use http:// scheme, not https:// \\n`#define PPG_URL \\\"http://pushapi.eval.blackberry.com”`\"\n}\n[/block]\n**1.** In your main App add push notifications service:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PushNotificationService m_pushNotificationService;  \",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**2.** Initialize push service:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"m_pushNotificationService.initializePushService(BLACKBERRY_APPID, PPG_URL, PUSHWOOSH_APP_ID, INVOKE_TARGET_KEY_PUSH, INVOKE_TARGET_KEY_OPEN);  \\n\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nNote that **INVOKE_TARGET_KEY_PUSH** must match the invoke target specified in **bar-descriptor.xml**. For example, here is Invoke target key for receiving new push notifications:\n\n`com.pushwoosh.example.invoke.push`\n\nNote that **INVOKE_TARGET_KEY_OPEN** must match the invoke target specified in **bar-descriptor.xml**. Here is a sample of an Invoke target key for selecting notification in the BlackBerry Hub:\n\n`com.pushwoosh.example.invoke.open`\n\n**3.** Connect push notification service signals and slots:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"QObject::connect(&m_pushNotificationService, SIGNAL(registeredForPushNotifications(const QString &)),  \\n        this, SLOT(registeredForPushNotifications(const QString &)));  \\n \\nQObject::connect(&m_pushNotificationService, SIGNAL(errorRegisteringForPushNotifications(const QString &)),  \\n        this, SLOT(errorRegisteringForPushNotifications(const QString &)));  \\n\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nExample of callback functions:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"void App::registeredForPushNotifications(const QString & token)  \\n{  \\n    qDebug() << \\\"subscribed for push with token: \\\" << token;  \\n}  \\n \\nvoid App::errorRegisteringForPushNotifications(const QString & error)  \\n{  \\n    qDebug() << \\\"error subscribing for push: \\\" << error;  \\n}  \",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**4.** Initialize push session:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"m_pushNotificationService.createSession();\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**5.** Subscribe for push notifications:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"m_pushNotificationService.registerForPushNotifications();\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**6.** Handle push notifications:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"void App::onInvoked(const InvokeRequest &request)  \\n{  \\n    if (request.action().compare(BB_PUSH_INVOCATION_ACTION) == 0) {  \\n        qDebug() << \\\"Received push action\\\";  \\n        // Received an incoming push  \\n        // Extract it from the invoke request and then process it  \\n        PushPayload payload(request);  \\n        if (payload.isValid()) {  \\n            //call pushwoosh handler for stats etc.  \\n            m_pushNotificationService.pushNotificationHandler(pushPayload);  \\n \\n            //handle push  \\n        }  \\n    } else if (request.action().compare(BB_OPEN_INVOCATION_ACTION) == 0){  \\n        qDebug() << \\\"Received open action\\\";  \\n        // Received an invoke request to open an existing push (ie. from a notification in the BlackBerry Hub)  \\n        // The payload from the open invoke is the seqnum for the push in the database  \\n        // Process opened push here  \\n    }  \\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**7.** In bar-description.xml add permissions for push and device info:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<permission system=\\\"true\\\">_sys_use_consumer_push</permission>  \\n<permission>read_device_identifying_information</permission>  \\n<permission>post_notification</permission>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n**8.** Also add Invoke actions:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<!-- Need to put an invoke entry here for push -->  \\n<!-- The id here must match the invokeTargetID in the PushService constructor -->  \\n<invoke-target id=\\\"INVOKE_TARGET_KEY_PUSH\\\">  \\n  <type>APPLICATION</type>  \\n  <filter>  \\n     <action>bb.action.PUSH</action>  \\n     <mime-type>application/vnd.push</mime-type>  \\n  </filter>  \\n</invoke-target>  \\n \\n<!-- Have an invoke entry here for when a notification is clicked on in the BlackBerry Hub -->  \\n<!-- This will cause the application to be opened -->  \\n<invoke-target id=\\\"INVOKE_TARGET_KEY_OPEN\\\">  \\n  <type>APPLICATION</type>  \\n  <filter>  \\n     <action>bb.action.OPEN</action>  \\n     <mime-type>text/plain</mime-type>  \\n  </filter>  \\n</invoke-target>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nThat’s it, now the application should be able to subscribe a device to receive push notifications, and receive them properly.\n\n**Get/Set tags:**\n\nInclude necessary headers:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#include \\\"pushwoosh/request/PWRequest.h\\\"\\n#include \\\"pushwoosh/request/PWSetTagsRequest.h\\\"\\n#include \\\"pushwoosh/request/PWGetTagsRequest.h\\\"\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nDefine callback SLOTS:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"void App::setTagsFinished(PWRequest * request)\\n{\\n    if(!request->isValid())\\n    {\\n        QString error = request->getError();\\n        qDebug() << \\\"Set Tags Error: \\\" << error;\\n        return;\\n    }\\n \\n    qDebug() << \\\"Set Tags Success\\\";\\n}\\n \\nvoid App::getTagsFinished(PWRequest * request)\\n{\\n    if(!request->isValid())\\n    {\\n        QString error = request->getError();\\n        qDebug() << \\\"Get Tags Error: \\\" << error;\\n        return;\\n    }\\n \\n    PWGetTagsRequest * req = (PWGetTagsRequest *) request;\\n    QVariantMap tags = req->getTags();\\n \\n    QString reqString;\\n    bb::data::JsonDataAccess jda;\\n    jda.saveToBuffer(tags, &reqString);\\n \\n    qDebug() << \\\"Get Tags Success: \\\" << reqString;\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nTo set tags call:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"QVariantMap map;\\nmap[\\\"Hello\\\"] = 5;\\nmap[\\\"String\\\"] = \\\"Value\\\";\\n \\nQList<QString> array;\\narray.push_back(QString(\\\"One\\\"));\\narray.push_back(QString(\\\"Two\\\"));\\nmap[\\\"Array\\\"] = QVariant(array);\\n \\nm_pushNotificationService.setTags(map, this, SLOT(setTagsFinished(PWRequest*)));\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nTo get tags call:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"m_pushNotificationService.getTags(this, SLOT(getTagsFinished(PWRequest*)));\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"BlackBerry Cascades Integration Guide","slug":"blackberry-10-cascades","type":"basic","title":"BlackBerry 10 Cascades"}

BlackBerry 10 Cascades

BlackBerry Cascades Integration Guide

[**Download SDK**](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/BlackBerry10-Cascades) [**Download Sample**](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/Samples/Blackberry-Cascades) SDK contains the source code for BlackBerry 10 Cascades platform. [download](https://github.com/Pushwoosh/pushwoosh-blackberry-sdk/tree/master/BlackBerry10-Cascades) it from our repo first. List the libraries to be defined in the **.pro** file to avoid compilation error: [block:code] { "codes": [ { "code": "LIBS += -lbb\nLIBS += -lbbdevice\nLIBS += -lbbsystem\nLIBS += -lbbnetwork\nLIBS += -lbbplatform\nLIBS += -lbbdata", "language": "java" } ] } [/block] [block:callout] { "type": "warning", "body": "IMPORTANT: For push evaluation the PPG_URL should use http:// scheme, not https:// \n`#define PPG_URL \"http://pushapi.eval.blackberry.com”`" } [/block] **1.** In your main App add push notifications service: [block:code] { "codes": [ { "code": "PushNotificationService m_pushNotificationService; ", "language": "javascript" } ] } [/block] **2.** Initialize push service: [block:code] { "codes": [ { "code": "m_pushNotificationService.initializePushService(BLACKBERRY_APPID, PPG_URL, PUSHWOOSH_APP_ID, INVOKE_TARGET_KEY_PUSH, INVOKE_TARGET_KEY_OPEN); \n", "language": "javascript" } ] } [/block] Note that **INVOKE_TARGET_KEY_PUSH** must match the invoke target specified in **bar-descriptor.xml**. For example, here is Invoke target key for receiving new push notifications: `com.pushwoosh.example.invoke.push` Note that **INVOKE_TARGET_KEY_OPEN** must match the invoke target specified in **bar-descriptor.xml**. Here is a sample of an Invoke target key for selecting notification in the BlackBerry Hub: `com.pushwoosh.example.invoke.open` **3.** Connect push notification service signals and slots: [block:code] { "codes": [ { "code": "QObject::connect(&m_pushNotificationService, SIGNAL(registeredForPushNotifications(const QString &)), \n this, SLOT(registeredForPushNotifications(const QString &))); \n \nQObject::connect(&m_pushNotificationService, SIGNAL(errorRegisteringForPushNotifications(const QString &)), \n this, SLOT(errorRegisteringForPushNotifications(const QString &))); \n", "language": "javascript" } ] } [/block] Example of callback functions: [block:code] { "codes": [ { "code": "void App::registeredForPushNotifications(const QString & token) \n{ \n qDebug() << \"subscribed for push with token: \" << token; \n} \n \nvoid App::errorRegisteringForPushNotifications(const QString & error) \n{ \n qDebug() << \"error subscribing for push: \" << error; \n} ", "language": "javascript" } ] } [/block] **4.** Initialize push session: [block:code] { "codes": [ { "code": "m_pushNotificationService.createSession();", "language": "javascript" } ] } [/block] **5.** Subscribe for push notifications: [block:code] { "codes": [ { "code": "m_pushNotificationService.registerForPushNotifications();", "language": "javascript" } ] } [/block] **6.** Handle push notifications: [block:code] { "codes": [ { "code": "void App::onInvoked(const InvokeRequest &request) \n{ \n if (request.action().compare(BB_PUSH_INVOCATION_ACTION) == 0) { \n qDebug() << \"Received push action\"; \n // Received an incoming push \n // Extract it from the invoke request and then process it \n PushPayload payload(request); \n if (payload.isValid()) { \n //call pushwoosh handler for stats etc. \n m_pushNotificationService.pushNotificationHandler(pushPayload); \n \n //handle push \n } \n } else if (request.action().compare(BB_OPEN_INVOCATION_ACTION) == 0){ \n qDebug() << \"Received open action\"; \n // Received an invoke request to open an existing push (ie. from a notification in the BlackBerry Hub) \n // The payload from the open invoke is the seqnum for the push in the database \n // Process opened push here \n } \n}", "language": "javascript" } ] } [/block] **7.** In bar-description.xml add permissions for push and device info: [block:code] { "codes": [ { "code": "<permission system=\"true\">_sys_use_consumer_push</permission> \n<permission>read_device_identifying_information</permission> \n<permission>post_notification</permission>", "language": "xml" } ] } [/block] **8.** Also add Invoke actions: [block:code] { "codes": [ { "code": "<!-- Need to put an invoke entry here for push --> \n<!-- The id here must match the invokeTargetID in the PushService constructor --> \n<invoke-target id=\"INVOKE_TARGET_KEY_PUSH\"> \n <type>APPLICATION</type> \n <filter> \n <action>bb.action.PUSH</action> \n <mime-type>application/vnd.push</mime-type> \n </filter> \n</invoke-target> \n \n<!-- Have an invoke entry here for when a notification is clicked on in the BlackBerry Hub --> \n<!-- This will cause the application to be opened --> \n<invoke-target id=\"INVOKE_TARGET_KEY_OPEN\"> \n <type>APPLICATION</type> \n <filter> \n <action>bb.action.OPEN</action> \n <mime-type>text/plain</mime-type> \n </filter> \n</invoke-target>", "language": "xml" } ] } [/block] That’s it, now the application should be able to subscribe a device to receive push notifications, and receive them properly. **Get/Set tags:** Include necessary headers: [block:code] { "codes": [ { "code": "#include \"pushwoosh/request/PWRequest.h\"\n#include \"pushwoosh/request/PWSetTagsRequest.h\"\n#include \"pushwoosh/request/PWGetTagsRequest.h\"", "language": "java" } ] } [/block] Define callback SLOTS: [block:code] { "codes": [ { "code": "void App::setTagsFinished(PWRequest * request)\n{\n if(!request->isValid())\n {\n QString error = request->getError();\n qDebug() << \"Set Tags Error: \" << error;\n return;\n }\n \n qDebug() << \"Set Tags Success\";\n}\n \nvoid App::getTagsFinished(PWRequest * request)\n{\n if(!request->isValid())\n {\n QString error = request->getError();\n qDebug() << \"Get Tags Error: \" << error;\n return;\n }\n \n PWGetTagsRequest * req = (PWGetTagsRequest *) request;\n QVariantMap tags = req->getTags();\n \n QString reqString;\n bb::data::JsonDataAccess jda;\n jda.saveToBuffer(tags, &reqString);\n \n qDebug() << \"Get Tags Success: \" << reqString;\n}", "language": "java" } ] } [/block] To set tags call: [block:code] { "codes": [ { "code": "QVariantMap map;\nmap[\"Hello\"] = 5;\nmap[\"String\"] = \"Value\";\n \nQList<QString> array;\narray.push_back(QString(\"One\"));\narray.push_back(QString(\"Two\"));\nmap[\"Array\"] = QVariant(array);\n \nm_pushNotificationService.setTags(map, this, SLOT(setTagsFinished(PWRequest*)));", "language": "java" } ] } [/block] To get tags call: [block:code] { "codes": [ { "code": "m_pushNotificationService.getTags(this, SLOT(getTagsFinished(PWRequest*)));", "language": "java" } ] } [/block]