Leveraging BlackBerry Services: Push and Notification Manager JAM848 Garett Beukeboom, Application Development Consultant, RIM Vineet Narang, CEO, MobiQuest November 30 th, 2012
BlackBerry Push Service Overview
What is Push? Proactive, efficient and immediate data delivery system Huge benefits over polling and poke/pull Same system used to deliver BBM messages etc Allows data payload delivery up to 8KB Supported across all BlackBerry smartphones Device Out of Coverage Support Up to 30 Days Free Push Essentials is 100% free to use
Ways to Push Data BlackBerry Push Service Push through BlackBerry Infrastructure Supports Push Access Protocol (PAP) BlackBerry Enterprise Push Push through BlackBerry Enterprise Server Supports Push Access Protocol (PAP)
Push Workflow 1. The server sends PAP Push which contains a list of specified devices 2. The BlackBerry Push Service sends a response to the server and queues the request 3. The BlackBerry Push Service pushes the data to specified devices Push Initiator 4. Each device sends an ACK to the BlackBerry Push Service 5. BlackBerry Push Service sends a notification to the server 6. The server sends read notifications to BlackBerry Push Service BlackBerry Push Service Mobile Client
Server Side Development Changes required for BlackBerry 10 Standalone approach Push Service SDK
Changes for BlackBerry 10
Extend to BlackBerry 10 Push Initiator BlackBerry OS Devices BlackBerry 10 Devices
Server Side Development Standalone Approach You create and send PAP-formatted XML messages Can use any language/platform that can send an HTTP POST Provides the most flexibility and control Integrate into existing backend system Implement PAP protocol and subscription management
Sample Push Request Message --PMasdfglkjhqwert Content-Type: application/xml <?xml version="1.0"?> <!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN "http://www.openmobilealliance.org/tech/dtd/pap_2.1.dtd"> <pap> <push-message push-id= unique-push-id-created-by-you" source-reference= your-app-id" deliver-before-timestamp="2008-09-31t13:30:00z"> <address address-value="pin00001"/> <quality-of-service delivery-method="unconfirmed"/> </push-message> </pap> --PMasdfglkjhqwert Content-Encoding: binary Content-Type: text/html Text or binary content to be pushed to BlackBerry device goes here. --PMasdfglkjhqwert--
Sample Push Request Response <?xml version="1.0"?> <!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" "http://www.openmobilealliance.org/tech/dtd/pap_2.1.dtd"> <pap> <push-response push-id="unique-push-id-created-by-you" sender-address="https://www.pushdatadomain.com/pd_pushrequest" sender-name="rim Push-Data" reply-time="2008-09-31t13:00:00z"> <response-result code="1001" desc="accepted for Processing"> </response-result> </push-message> </pap>
Push Service SDK Approach Installable Suite of Services Java based APIs Create PAP messages (send message, query, cancel etc) Handle server responses Apache Tomcat web interface for registration and testing Provides starting point
Urban Airship http://go.urbanairship.com Cross-platform push service Simple application portal Test sending push messages Client and server samples/libraries available Sample Cascades application available now https://github.com/blackberry/cascades-community-samples
Registering for Push Services Register for an evaluation account Email with credentials and account information Download the Push Services SDK Push related documentation http://developer.blackberry.com/develop/platform_services/ push_overview.html -orhttp://bbry.lv/qh3vpp
Push Device Side Development Supported Development Approaches Application Permissions The Application LifeCycle Receiving Pushed Data in Your Application
Device Side Application Native Development Kit Qt / C++ API, Sample App, and Documentation HTML 5 / WebWorks SDK WebWorks API, Sample App, and Documentation AIR SDK AIR API, Sample App, and Documentation Android Runtime
Application Permissions <permission>read_device_identifying_information</permission> <permission>access_internet</permission> <permission>post_notification</permission> <action system="true">_sys_use_consumer_push</action>
Application Permissions _sys_use_consumer_push New for Beta 4 Needs to be added to the bar-descriptor.xml manually Permission needs to be requested for your code signing keys
Application LifeCycle
The Invocation Framework PNS Invocation Framework Your App
App Flow 1) Register with the Invocation framework 2) Register with the Push Notification Service (PNS) 3) Create a Channel with the Push Proxy Gateway (PPG) 4) Register to launch when a Push arrives 5) Read Push Payload 6) Display Notifications when Push Date arrives Handled by the PushService class Cascades Framework HTML5 / WebWorks HTML5 Code snippets taken from the pushcollector and pushcapture samples
Register with the Invocation Framework Add an <invoke-target> entry to the bar-descriptor.xml file: <invoke-target id="unique.text.value"> <type>application</type> <filter> <action>bb.action.push</action> <mime-type>application/vnd.push</mime-type> </filter> </invoke-target>
Register with PNS Register against PNS by passing two values Invoke Target ID Application ID PushService#createSession() is asynchronous PushService* m_pushservice = new PushService( your-app-id", "unique.text.value", this); m_pushservice->createsession(); blackberry.push.pushservice.create(ops, sample.pushcapture.successcreatepushservice, sample.pushcapture.failcreatepushservice, sample.pushcapture.onsimchange);
Create a channel with the PPG Create a channel with the PPG by passing the PPG URL Registers your device to allow it to receive pushes PushService#createChannel() is asynchronous m_pushservice-> createchannel(qurl("http://pushapi.eval.blackberry.com")); sample.pushcapture.pushservice.createchannel( sample.pushcapture.createchannelcallback);
Register to launch when a Push arrives m_pushservice->registertolaunch(); service.launchapplicationonpush(sample.pushcapture.launchapp, sample.pushcapture.launchapplicationcallback);
Receiving Payload Data InvokeManager *m_invokemanager = new InvokeManager(this); connect(m_invokemanager, SIGNAL(invoked(const bb::system::invokerequest&)), this, SLOT(handleInvoke(const bb::system::invokerequest&)));
Receiving Payload Data void App::handleInvoke(const InvokeRequest &request) { Application::instance()->setIconBadge(bb::IconBadge::Splat); } if (request.action().compare("bb.action.push")!= 0) { return; } PushPayload payload(request); if (payload.isvalid()) { if (payload.isackrequired()) { m_pushservice->acceptpush(payload.id()); } }
Receiving Payload Data blackberry.event.addeventlistener("invoked", sample.pushcapture.oninvoke);
Receiving Payload Data PushCapture.prototype.onInvoke = function(invokerequest) { if (invokerequest.action!= null && invokerequest.action == "bb.action.push") { if (sample.pushcapture.pushservice!= null) { var pushpayload = sample.pushcapture.pushservice.extractpushpayload(invokerequest); if (pushpayload.isacknowledgerequired) { pushpayload.acknowledge(true); } } else { console.log("error: No PushService instance was available to extract the push."); } } };
Additional Thoughts How does the Push Initiator know the app has been installed? The application can initiate a subscribe request Token generated during Channel creation includes device-specific information (PIN) Displayed in the sample apps What if the user changes their SIM card? PushService has a signal/callback when this occurs Handle accordingly
Vineet Narang, CEO, MobiQuest Demonstration and Discussion Taylormade Golf for BlackBerry 10
Overview m loyal APP Business Use Case & Screen Shots Technology Use case All BlackBerry 10 Functionality / Push Functionality usage details Demo
Business Case Loyalty in the smart phone era 33
Program Objectives Creating a special experience for the customer with a personalized app Establishing Customer Connect with PUSH notifications Reward them for their patronage with an inbuilt Reward Store Customer Retention
Business Benefits Multi-Channel Customer Acquisition Customer Connect Push Notifications enable INSTANT connect with customer Push instant Customer Rewards. M-vouchers Integratable with Social Mobile Couponing System
Features Dynamic App Integrates with Point of Sale Data Real Time Loyalty Points Update Reward Store for m- Vouchers on Brand/Cross Brand Rewards Alerts/Notifications to user of SMS, Coupons and event/news/promo updates
37
Multichannel ecosystem
Ateet Gaur Managing Director- South East Asia Adidas Taylormade analyze customer behavior m Loyalty platform is a great idea, which has been practically successful in its objectives of customer acquisition, retention and engagement. It helped us to analyse customer behavior, preferences and today we have launched our special Taylormade loyalty club campaign- I am a Golfer - for our upcoming retail stores
Technology Usecase Notifications & Personalization 40
Login Screen Mobile Coupons The app will allow the customers to fill in the membership form of the brand They form the base tier in the loyalty Program
Rewards Store SMS Inbox
Push Notification Requirements Application Framework BlackBerry WebWorks SDK PushService PushPayLoad UI Framework JQM (JQuery Mobile) Other UI Frameworks can also be used Ripple Simulator with Google Chrome Push Notification will not work with Ripple Simulator 43
Implementation Steps Registration with PNS (Push Notification Service) The PNS is always running on BlackBerry 10 When your application first launches, it should always create a PushService session instance. This instance takes 2 primary values as parameters: 1. the Invoke Target and 2. Application ID. After this has been successfully created, the PNS now has a mapping between the Application ID and the Invoke Target. ops = { invoketargetid : invoketargetid, appid : appid, ppgurl : ppgurl };blackberry.push.pushservice.create(ops, successcreatepushservice, failcreatepushservice, onsimchange,onpushtransportready);
Implementation Steps Registering with the Push Service The process of registering with BPS is known as creating a channel. This tells BPS that the device has the required application installed and that it would like to start receiving pushed data. PushService.createChannel(createChannelCallback) 45
Implementation Steps Handling the Push Invocation when the client app is closed There is a method that can be called which will allow the application to launch in the background when a Push arrives. pushservice.launchapplicationonpush(launchapp, launchapplicationcallback); If this is set to true, then the application will launch as soon as a Push is received and run in a minimized state 46
Implementation Steps Receiving Payload Data and Handling Invocation We need to add Event Listener and call oninvoke() method blackberry.event.addeventlistener("invoked", oninvoke) function oninvoke(invokerequest) { if (invokerequest.action!= null && invokerequest.action == "bb.action.push") { if (pushservice == null) { // Wait a bit for the PushService instance to be created and then try again settimeout(function() { oninvoke(invokerequest); }, 750); } else if (pushservice!= null) {
Contd. var pushpayload = pushservice.extractpushpayload(invokerequest); pushnotificationhandler(pushpayload); notify_app= new Notification("simple notification");//for Splat Icon and LED Notification } else { alert("error: No PushService instance was available to extract the push."); } } } 48
Notification Development Notification Types Notification Scheme
Device Side Application Native Development Kit C/C++, Cascades Framework HTML 5 / WebWorks SDK AIR SDK Android Runtime
Types of Notifications Notifications Integrates with the Notifications settings Integrates with the BlackBerry Hub* Displays splat icon on application automatically! Notification Dialogs Displays dialog atop the UI
Application Permissions Permissions <permission>post_notification</permission> Customization Custom sounds can be played, but should be done so sparingly!
Anatomy of a Notification Title* Body* Sound URL InvokeRequest* *Current *Future
Anatomy of a Notification Creating a Notification bb::platform::notification* m_notification = new Notification(); Firing a Notification m_notification->notify(); Clearing a Notification m_notification->cleareffectsforall();
Effects of a Notification
Anatomy of a NotificationDialog Title Body Repeat Sound URL SystemUiButton(s)**
Effects of a Notification
Anatomy of a Notification Creating a NotificationDialog bb::platform::notificationdialog* m_notificationdialog = new NotificationDialog(); m_notificationdialog->settitle("push Received"); m_notificationdialog->appendbutton(new SystemUiButton("Dismiss")); m_notificationdialog->setbody(pushmessage); Display the NotificationDialog m_notificationdialog->show(); m_notificationdialog->exec(); m_notificationdialog->cancel(); Respond to the user interaction SystemUiButton* button = m_notificationdialog->buttonselection();
Questions & Answers Sign up to try the BlackBerry Push Services: http://bbry.lv/qh3vpp Download BlackBerry 10 client samples https://developer.blackberry.com https://github.com/blackberry
And a few Quick Notes Don t forget to fill out the Conference Survey at the Registration Desk to claim a free gift! THANK YOU for helping us make this event such a great success!!! 60
THANK YOU JAM848 Garett Beukeboom, Application Development Consultant, RIM Vineet Narang, CEO, MobiQuest November 30 th, 2012