SlideShare una empresa de Scribd logo
1 de 25
BlackBerry Push
Infrastructure at Work:
Introduction to the
BlackBerry Push API
Pratik Sapra
Application Development Specialist
BlackBerry Push Infrastructure at Work:
Introduction to the BlackBerry Push API
• Overview
• Architecture
• Implementation
• Security & Reliability
• Requesting Access
Why use Push?
• The data is on the device when the user needs it
• Data is delivered as soon as it is available
• Application is always actively listening for data arrival
• User can be immediately notified of new data
• Audio alert, vibration, blinking LED, pop-up dialog,
icon change, banner notification
• The user experience is that it just happened
• appearance of zero latency
Push Vs Poke-Pull
• Push
• Allows the delivery of content to a device without the device having to
request it
• The data is sent to a port on the device where an application is listening
for it
• Push is generally server based/mediated
• Push Initiator
• The Push Initiator submits a request to the Hosted Data Push Service
• Contains delivery instructions and the payload
– Delivery instructions describe where and how the data is to be
sent
– The payload may be any type of data
• Poke-and-Pull
• Poke: a notification and URL are pushed to a device
• Pull: the device fetches the content at the URL
• Less efficient than true push
BlackBerry Push API
• Compare to Polling
• Client periodically asks a server if an event of interest has
occurred
• Inefficient – increases OTA costs and traffic
• there may be many polling attempts to fetch a single
event
• Delays in getting data due to polling latency (interval)
• Depending on polling interval, received data may be
outdated
• Wastes battery life checking whether an event of interest has
occurred
• Generates extra server traffic and load for your application
• 1,000,000 devices x 12 polls/hr x 24 hours =
288,000,000 requests per day
• Doesn’t scale
BlackBerry Push API
• Provides a transport infrastructure for Server to Device pushed
data
• Primary focus on consumer applications
• Alerts
• Replace polling to improve performance & reduce costs
• Poke-Pull model
• Event driven systems
• Near real-time notifications
• Can be used for enterprise deployments
• Cross company applications
• Enterprises without a BlackBerry Enterprise Server
Benefits
• Provides information immediately
• Optimizes network efficiency
• Preserves the battery life
• Reduces complexity for developers
• Improves developer margins
Architecture
• Pushes are initiated on the Server
• Server side application is required
• Server to Server interface for the Push Initiator
• BlackBerry Infrastructure is the middleware
• Sends data to a specified port on the Device
• Client side Java application required to receive the push
• Uses PAP 2.2 Standard push protocols
• OMA-WAP-TS-PAP-V2_2-20071002-C
• Requests are HTTP XML requests
• Supported requests:
• Submit Push
• Cancel Push
• Query for Status
• Response:
• Result notification
Components
Three major components:
• The server-side push service
• A client-side application
• BlackBerry Infrastructure
Push Workflow
Mobile Client
Push Request
Response BlackBerry
Infrastructure
1
2
3
4
5
6
Push
Push
Initiator
1. Server sends PAP Push which
contains a list of specified devices
2. BlackBerry Infrastructure sends
response to Server and queues
request
3. BlackBerry Infrastructure pushes data
to specified devices
4. Each device sends ACK to
BlackBerry Infrastructure
5. BlackBerry Infrastructure sends
notification to Server
6. Server sends Read notification to
BlackBerry Infrastructure
About the Push
• Push sent to user’s PIN
• Maximum payload is 8 KB
• Types of Push:
• Point to Point (Single PIN)
• Multicast (List of PINs)
• Broadcast (All PINs by application)
• BlackBerry Infrastructure will attempt to deliver the
message until expiry time
• Automatic retries if device is out of coverage
• Expiry time can be configured to a maximum of 8 hours
Sample Push Request
--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="999999999"
source-reference="AAAAAAAAAAAA"
deliver-before-timestamp="2008-09-31T13:30:00Z"
ppg-notify-requested-to="notify_url_path">
<address address-value="PIN00001"/>
<address address-value="PIN00002"/>
<address address-value="PIN00003"/>
<quality-of-service delivery-method="confirmed"/>
</push-message>
</pap>
--PMasdfglkjhqwert
Content-Encoding: binary
Content-Type: text/html
Text or binary content to be delivered to BlackBerry device goes here.
--PMasdfglkjhqwert--
Sample Code: Push Request (1 of 2)
HttpURLConnection mdsConn = null;
InputStream ins = null;
OutputStream outs = null;
String errorCode = null;
try
{
URL mdsUrl = new URL(BLACKBERRY_INFRASTRUCTURE_URL);
mdsConn = (HttpURLConnection) mdsUrl.openConnection();
String boundary = "";
boundary = "asdlfkjiurwghasf";
mdsConn.setRequestProperty("Content-Type",
"multipart/related; type="application/xml";boundary=" + boundary);
String auth = "Basic " + new BASE64Encoder().encode((_psid + ":" + _password).getBytes());
mdsConn.setRequestProperty("Authorization", auth);
mdsConn.setRequestMethod("POST");
mdsConn.setAllowUserInteraction(false);
mdsConn.setDoInput(true);
mdsConn.setDoOutput(true);
/* … Continued on next slide … */
Sample Code: Push Request (2 of 2)
String papPush = “…”; //push message
outs = mdsConn.getOutputStream();
copyStreams(new ByteArrayInputStream(output.getBytes()), outs);
mdsConn.connect();
ins = mdsConn.getInputStream();
ByteArrayOutputStream response = new ByteArrayOutputStream();
copyStreams(ins, response);
int httpCode = mdsConn.getResponseCode();
if( httpCode != HttpURLConnection.HTTP_ACCEPTED && httpCode != HttpURLConnection.HTTP_OK )
{
//Push failed
}
else
{
//HTTP Connection successful
//Parse the response notification message to confirm successful push (not shown here)
}
} catch(Exception ex)
{
errorCode = ex.getClass().getName();
} finally { /* close input and output streams and close the connection */ }
Sample Cancel Request
• Any queued pushes can be cancelled
• Previously pushed content cannot be recalled
• Result notification sent from BlackBerry Infrastructure
– Confirms for which devices the pushes were and
were not cancelled
• Uses WAP PAP <cancel-message> element
Sample Cancel Request
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>
<cancel-message push-id="999999999">
<address address-value="PIN00001"/>
<address address-value="PIN00002"/>
<address address-value="PIN00003"/>
</cancel-message>
</pap>
Status Request
• Query for the status of a submitted request
• Status is maintained for 24 hours
• If multiple recipients
• response will contain a status for all of them
• Status is a snapshot
• i.e. reflective only of the current moment in time
• Uses WAP PAP <statusquery-message> element
Sample Status Request
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>
<statusquery-message push-id="999999999">
</statusquery-message>
</pap>
Response Notifications
• Sent to the Server URL if specified, none otherwise
• Be prepared to handle these – there will be many of
them
– Quality of Service Levels
• Application
– Message reached the application
• Transport
– Message reached the device
• None
– Fire and forget
Listening for Push
• User installs mobile application
• On first run, mobile application registers with
BlackBerry Infrastructure
– Creates HTTPS connection to Infrastructure URL
• Headers identify PIN and PSID
• BlackBerry Infrastructure validates the mobile
application
• BlackBerry Infrastructure returns pass/fail to mobile
application
Sample Code: Listening for Push
StreamConnection stream;
InputStream ins;
MDSPushInputStream pushInputStream;
//use the port assigned to your application
StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open("http://:110");
while( !_stop )
{
stream = _notifier.acceptAndOpen(); //blocking operation
input = stream.openInputStream();
pushInputStream = new MDSPushInputStream((HttpServerConnection) stream, input);
DataBuffer buffer = new DataBuffer();
byte[] data = new byte[ 256 ];
int chunk = 0;
while( -1 != (chunk = input.read(data)) )
{
buffer.write(data, 0, chunk);
}
/* … process the data on the DataBuffer ... */
// Signal that we have finished reading.
pushInputStream.accept();
}
Security
• BlackBerry Infrastructure Authentication
• Push Initiator is authenticated to the BlackBerry Infrastructure
• Push Initiator can only push to its mobile application
• 1:1 relationship between Push Initiator and mobile application
• Push Initiator can only push to devices registered for their
application
• Each push request is authenticated to BlackBerry Infrastructure
• Unique listening port for each application
• BlackBerry Infrastructure does not encrypt data
• Expects that payload data will already be encrypted by Push
Initiator
• Content Provider Authentication
• Mobile application should be authenticated to the Push Initiator
Reliability
• Choose the appropriate QoS for your application
• There are tradeoffs for performance and battery life
• Be sure to handle all request failures in your application
• Result notifications
• Your server app must be prepared to handle these, if you
request them
• Server outages - RIM infrastructure will retry deliveries … for
a while
• Always provide an unsubscribe option in your device application
• Highest reliability can be achieved by application
acknowledgement direct to your server
Requesting Access
• Register at www.blackberry.com/pushapi
• Sample code provided on registration approval
• Content Provider tests the push service
• Given access to the evaluation infrastructure
• Research In Motion validates the Content Provider’s client and
server-side applications
• Ensuring development guidelines are met
• Service is moved into production
• Once all requirements are met
• Only available to ISV Alliance Partners
• To become an ISV Alliance partner visit
www.blackberry.com/allianceapplication
• Contact for service costs
Thank You
Pratik Sapra – Application Development Specialist

Más contenido relacionado

La actualidad más candente

Server And Hardware Virtualization_Aakash1.1
Server And Hardware Virtualization_Aakash1.1Server And Hardware Virtualization_Aakash1.1
Server And Hardware Virtualization_Aakash1.1
Aakash Agarwal
 

La actualidad más candente (19)

Messaging for IoT
Messaging for IoTMessaging for IoT
Messaging for IoT
 
Patterns of Distributed Application Design
Patterns of Distributed Application DesignPatterns of Distributed Application Design
Patterns of Distributed Application Design
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor Framework
 
6421 b Module-02
6421 b Module-026421 b Module-02
6421 b Module-02
 
Secured REST Microservices with Spring Cloud
Secured REST Microservices with Spring CloudSecured REST Microservices with Spring Cloud
Secured REST Microservices with Spring Cloud
 
6421 b Module-06
6421 b Module-066421 b Module-06
6421 b Module-06
 
E-DHCP
E-DHCPE-DHCP
E-DHCP
 
GPA Software Overview R3
GPA Software Overview R3GPA Software Overview R3
GPA Software Overview R3
 
Null talk
Null talkNull talk
Null talk
 
Forefront UAG
Forefront UAGForefront UAG
Forefront UAG
 
Server And Hardware Virtualization_Aakash1.1
Server And Hardware Virtualization_Aakash1.1Server And Hardware Virtualization_Aakash1.1
Server And Hardware Virtualization_Aakash1.1
 
Network and server performance monitoring training
Network and server performance monitoring trainingNetwork and server performance monitoring training
Network and server performance monitoring training
 
Open programmable architecture for java enabled network devices
Open programmable architecture for java enabled network devicesOpen programmable architecture for java enabled network devices
Open programmable architecture for java enabled network devices
 
Open Programmable Architecture for Java-enabled Network Devices
Open Programmable Architecture for Java-enabled Network DevicesOpen Programmable Architecture for Java-enabled Network Devices
Open Programmable Architecture for Java-enabled Network Devices
 
Introduction to Software Defined Networking (SDN)
Introduction to Software Defined Networking (SDN)Introduction to Software Defined Networking (SDN)
Introduction to Software Defined Networking (SDN)
 
ACE - Comcore
ACE - ComcoreACE - Comcore
ACE - Comcore
 
Nexus 1000_ver 1.1
Nexus 1000_ver 1.1Nexus 1000_ver 1.1
Nexus 1000_ver 1.1
 
ppt
pptppt
ppt
 
Dhcp authentication using certificates
Dhcp authentication using certificatesDhcp authentication using certificates
Dhcp authentication using certificates
 

Destacado

Nakajima0622 Devlovetest
Nakajima0622 DevlovetestNakajima0622 Devlovetest
Nakajima0622 Devlovetest
DevLOVE
 
La Renaixença
La RenaixençaLa Renaixença
La Renaixença
asanchez
 
Neurologa rita levi-montalcini
Neurologa rita levi-montalciniNeurologa rita levi-montalcini
Neurologa rita levi-montalcini
Arnaldo Carvalho
 
Sala Delfines 2010
Sala Delfines 2010Sala Delfines 2010
Sala Delfines 2010
martinyomar
 

Destacado (15)

Nakajima0622 Devlovetest
Nakajima0622 DevlovetestNakajima0622 Devlovetest
Nakajima0622 Devlovetest
 
La Renaixença
La RenaixençaLa Renaixença
La Renaixença
 
Neurologa rita levi-montalcini
Neurologa rita levi-montalciniNeurologa rita levi-montalcini
Neurologa rita levi-montalcini
 
jammer
jammerjammer
jammer
 
Audio como ser una buena educadora
Audio como ser una buena educadoraAudio como ser una buena educadora
Audio como ser una buena educadora
 
Gray - Cnu Denver And Hud
Gray - Cnu Denver And HudGray - Cnu Denver And Hud
Gray - Cnu Denver And Hud
 
Ewrt 2 class 18
Ewrt 2 class 18Ewrt 2 class 18
Ewrt 2 class 18
 
Iedereen verkoper
Iedereen verkoperIedereen verkoper
Iedereen verkoper
 
Pp risk assessment_
Pp risk assessment_Pp risk assessment_
Pp risk assessment_
 
10 Sagrada Escritura
10 Sagrada Escritura10 Sagrada Escritura
10 Sagrada Escritura
 
Ewrt 30 class 10 for sub
Ewrt 30 class 10 for subEwrt 30 class 10 for sub
Ewrt 30 class 10 for sub
 
Does Our Lord really dislike yeast (leaven) and why
Does Our Lord really dislike yeast (leaven) and whyDoes Our Lord really dislike yeast (leaven) and why
Does Our Lord really dislike yeast (leaven) and why
 
CV
CVCV
CV
 
Siemens: Optimized concepts for loading & installing offshore wind turbines
Siemens: Optimized concepts for loading & installing offshore wind turbinesSiemens: Optimized concepts for loading & installing offshore wind turbines
Siemens: Optimized concepts for loading & installing offshore wind turbines
 
Sala Delfines 2010
Sala Delfines 2010Sala Delfines 2010
Sala Delfines 2010
 

Similar a Bb push sapra

Research In Motion &quot;Blackberry&quot;
Research In Motion &quot;Blackberry&quot;Research In Motion &quot;Blackberry&quot;
Research In Motion &quot;Blackberry&quot;
devalnaik
 
Computer Networks notes 5- Module 5.pptx
Computer Networks notes 5- Module 5.pptxComputer Networks notes 5- Module 5.pptx
Computer Networks notes 5- Module 5.pptx
SmithaV19
 
Issues in Designing Push Based Mobile Application Platform - Rafiul Ahad, Oracle
Issues in Designing Push Based Mobile Application Platform - Rafiul Ahad, OracleIssues in Designing Push Based Mobile Application Platform - Rafiul Ahad, Oracle
Issues in Designing Push Based Mobile Application Platform - Rafiul Ahad, Oracle
mfrancis
 

Similar a Bb push sapra (20)

Research In Motion &quot;Blackberry&quot;
Research In Motion &quot;Blackberry&quot;Research In Motion &quot;Blackberry&quot;
Research In Motion &quot;Blackberry&quot;
 
Computer Networks notes 5- Module 5.pptx
Computer Networks notes 5- Module 5.pptxComputer Networks notes 5- Module 5.pptx
Computer Networks notes 5- Module 5.pptx
 
PLNOG15: Simplifying network deployment using Autonomic networking and Plug-a...
PLNOG15: Simplifying network deployment using Autonomic networking and Plug-a...PLNOG15: Simplifying network deployment using Autonomic networking and Plug-a...
PLNOG15: Simplifying network deployment using Autonomic networking and Plug-a...
 
IzoT platform presentation
IzoT platform presentationIzoT platform presentation
IzoT platform presentation
 
KKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - AntonyKKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - Antony
 
Global Data Stream Network for Internet of Things
Global Data Stream Network for Internet of ThingsGlobal Data Stream Network for Internet of Things
Global Data Stream Network for Internet of Things
 
FIWARE Tech Summit - FIWARE NGSIv2 Introduction
FIWARE Tech Summit - FIWARE NGSIv2 IntroductionFIWARE Tech Summit - FIWARE NGSIv2 Introduction
FIWARE Tech Summit - FIWARE NGSIv2 Introduction
 
Deploy secure, scalable, and highly available web apps with Azure Front Door ...
Deploy secure, scalable, and highly available web apps with Azure Front Door ...Deploy secure, scalable, and highly available web apps with Azure Front Door ...
Deploy secure, scalable, and highly available web apps with Azure Front Door ...
 
Get More Data Into Your SCADA
Get More Data Into Your SCADAGet More Data Into Your SCADA
Get More Data Into Your SCADA
 
Opal: Simple Web Services Wrappers for Scientific Applications
Opal: Simple Web Services Wrappers for Scientific ApplicationsOpal: Simple Web Services Wrappers for Scientific Applications
Opal: Simple Web Services Wrappers for Scientific Applications
 
Splunk MINT for Mobile Intelligence and Splunk App for Stream for Enhanced Op...
Splunk MINT for Mobile Intelligence and Splunk App for Stream for Enhanced Op...Splunk MINT for Mobile Intelligence and Splunk App for Stream for Enhanced Op...
Splunk MINT for Mobile Intelligence and Splunk App for Stream for Enhanced Op...
 
Get More Data Into Your SCADA 2016
Get More Data Into Your SCADA 2016Get More Data Into Your SCADA 2016
Get More Data Into Your SCADA 2016
 
Issues in Designing Push Based Mobile Application Platform - Rafiul Ahad, Oracle
Issues in Designing Push Based Mobile Application Platform - Rafiul Ahad, OracleIssues in Designing Push Based Mobile Application Platform - Rafiul Ahad, Oracle
Issues in Designing Push Based Mobile Application Platform - Rafiul Ahad, Oracle
 
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
 
What’s New: Splunk App for Stream and Splunk MINT
What’s New: Splunk App for Stream and Splunk MINTWhat’s New: Splunk App for Stream and Splunk MINT
What’s New: Splunk App for Stream and Splunk MINT
 
Brkcrt 2214
Brkcrt 2214Brkcrt 2214
Brkcrt 2214
 
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suroDevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
 
Data Onboarding
Data Onboarding Data Onboarding
Data Onboarding
 
Data Onboarding
Data Onboarding Data Onboarding
Data Onboarding
 
Azure Web App services
Azure Web App servicesAzure Web App services
Azure Web App services
 

Más de RavingTiger

How to use the public folder
How to use the public folderHow to use the public folder
How to use the public folder
RavingTiger
 
Widgets neil
Widgets neilWidgets neil
Widgets neil
RavingTiger
 
Mvs mcmanus
Mvs mcmanusMvs mcmanus
Mvs mcmanus
RavingTiger
 
Keynote lessard
Keynote lessardKeynote lessard
Keynote lessard
RavingTiger
 
Webdev battacherjee
Webdev battacherjeeWebdev battacherjee
Webdev battacherjee
RavingTiger
 
Bb jde kirkup
Bb jde kirkupBb jde kirkup
Bb jde kirkup
RavingTiger
 

Más de RavingTiger (10)

Credit controlanddebtmanagementpolicy
Credit controlanddebtmanagementpolicyCredit controlanddebtmanagementpolicy
Credit controlanddebtmanagementpolicy
 
Top secret
Top secretTop secret
Top secret
 
How to use the public folder
How to use the public folderHow to use the public folder
How to use the public folder
 
Widgets neil
Widgets neilWidgets neil
Widgets neil
 
Mvs mcmanus
Mvs mcmanusMvs mcmanus
Mvs mcmanus
 
Keynote lessard
Keynote lessardKeynote lessard
Keynote lessard
 
Webdev battacherjee
Webdev battacherjeeWebdev battacherjee
Webdev battacherjee
 
Bb jde kirkup
Bb jde kirkupBb jde kirkup
Bb jde kirkup
 
Wk2 questions
Wk2 questionsWk2 questions
Wk2 questions
 
Wk3 questions
Wk3 questionsWk3 questions
Wk3 questions
 

Último

Último (20)

Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Bb push sapra

  • 1. BlackBerry Push Infrastructure at Work: Introduction to the BlackBerry Push API Pratik Sapra Application Development Specialist
  • 2. BlackBerry Push Infrastructure at Work: Introduction to the BlackBerry Push API • Overview • Architecture • Implementation • Security & Reliability • Requesting Access
  • 3. Why use Push? • The data is on the device when the user needs it • Data is delivered as soon as it is available • Application is always actively listening for data arrival • User can be immediately notified of new data • Audio alert, vibration, blinking LED, pop-up dialog, icon change, banner notification • The user experience is that it just happened • appearance of zero latency
  • 4. Push Vs Poke-Pull • Push • Allows the delivery of content to a device without the device having to request it • The data is sent to a port on the device where an application is listening for it • Push is generally server based/mediated • Push Initiator • The Push Initiator submits a request to the Hosted Data Push Service • Contains delivery instructions and the payload – Delivery instructions describe where and how the data is to be sent – The payload may be any type of data • Poke-and-Pull • Poke: a notification and URL are pushed to a device • Pull: the device fetches the content at the URL • Less efficient than true push
  • 5. BlackBerry Push API • Compare to Polling • Client periodically asks a server if an event of interest has occurred • Inefficient – increases OTA costs and traffic • there may be many polling attempts to fetch a single event • Delays in getting data due to polling latency (interval) • Depending on polling interval, received data may be outdated • Wastes battery life checking whether an event of interest has occurred • Generates extra server traffic and load for your application • 1,000,000 devices x 12 polls/hr x 24 hours = 288,000,000 requests per day • Doesn’t scale
  • 6. BlackBerry Push API • Provides a transport infrastructure for Server to Device pushed data • Primary focus on consumer applications • Alerts • Replace polling to improve performance & reduce costs • Poke-Pull model • Event driven systems • Near real-time notifications • Can be used for enterprise deployments • Cross company applications • Enterprises without a BlackBerry Enterprise Server
  • 7. Benefits • Provides information immediately • Optimizes network efficiency • Preserves the battery life • Reduces complexity for developers • Improves developer margins
  • 8. Architecture • Pushes are initiated on the Server • Server side application is required • Server to Server interface for the Push Initiator • BlackBerry Infrastructure is the middleware • Sends data to a specified port on the Device • Client side Java application required to receive the push • Uses PAP 2.2 Standard push protocols • OMA-WAP-TS-PAP-V2_2-20071002-C • Requests are HTTP XML requests • Supported requests: • Submit Push • Cancel Push • Query for Status • Response: • Result notification
  • 9. Components Three major components: • The server-side push service • A client-side application • BlackBerry Infrastructure
  • 10. Push Workflow Mobile Client Push Request Response BlackBerry Infrastructure 1 2 3 4 5 6 Push Push Initiator 1. Server sends PAP Push which contains a list of specified devices 2. BlackBerry Infrastructure sends response to Server and queues request 3. BlackBerry Infrastructure pushes data to specified devices 4. Each device sends ACK to BlackBerry Infrastructure 5. BlackBerry Infrastructure sends notification to Server 6. Server sends Read notification to BlackBerry Infrastructure
  • 11. About the Push • Push sent to user’s PIN • Maximum payload is 8 KB • Types of Push: • Point to Point (Single PIN) • Multicast (List of PINs) • Broadcast (All PINs by application) • BlackBerry Infrastructure will attempt to deliver the message until expiry time • Automatic retries if device is out of coverage • Expiry time can be configured to a maximum of 8 hours
  • 12. Sample Push Request --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="999999999" source-reference="AAAAAAAAAAAA" deliver-before-timestamp="2008-09-31T13:30:00Z" ppg-notify-requested-to="notify_url_path"> <address address-value="PIN00001"/> <address address-value="PIN00002"/> <address address-value="PIN00003"/> <quality-of-service delivery-method="confirmed"/> </push-message> </pap> --PMasdfglkjhqwert Content-Encoding: binary Content-Type: text/html Text or binary content to be delivered to BlackBerry device goes here. --PMasdfglkjhqwert--
  • 13. Sample Code: Push Request (1 of 2) HttpURLConnection mdsConn = null; InputStream ins = null; OutputStream outs = null; String errorCode = null; try { URL mdsUrl = new URL(BLACKBERRY_INFRASTRUCTURE_URL); mdsConn = (HttpURLConnection) mdsUrl.openConnection(); String boundary = ""; boundary = "asdlfkjiurwghasf"; mdsConn.setRequestProperty("Content-Type", "multipart/related; type="application/xml";boundary=" + boundary); String auth = "Basic " + new BASE64Encoder().encode((_psid + ":" + _password).getBytes()); mdsConn.setRequestProperty("Authorization", auth); mdsConn.setRequestMethod("POST"); mdsConn.setAllowUserInteraction(false); mdsConn.setDoInput(true); mdsConn.setDoOutput(true); /* … Continued on next slide … */
  • 14. Sample Code: Push Request (2 of 2) String papPush = “…”; //push message outs = mdsConn.getOutputStream(); copyStreams(new ByteArrayInputStream(output.getBytes()), outs); mdsConn.connect(); ins = mdsConn.getInputStream(); ByteArrayOutputStream response = new ByteArrayOutputStream(); copyStreams(ins, response); int httpCode = mdsConn.getResponseCode(); if( httpCode != HttpURLConnection.HTTP_ACCEPTED && httpCode != HttpURLConnection.HTTP_OK ) { //Push failed } else { //HTTP Connection successful //Parse the response notification message to confirm successful push (not shown here) } } catch(Exception ex) { errorCode = ex.getClass().getName(); } finally { /* close input and output streams and close the connection */ }
  • 15. Sample Cancel Request • Any queued pushes can be cancelled • Previously pushed content cannot be recalled • Result notification sent from BlackBerry Infrastructure – Confirms for which devices the pushes were and were not cancelled • Uses WAP PAP <cancel-message> element
  • 16. Sample Cancel Request 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> <cancel-message push-id="999999999"> <address address-value="PIN00001"/> <address address-value="PIN00002"/> <address address-value="PIN00003"/> </cancel-message> </pap>
  • 17. Status Request • Query for the status of a submitted request • Status is maintained for 24 hours • If multiple recipients • response will contain a status for all of them • Status is a snapshot • i.e. reflective only of the current moment in time • Uses WAP PAP <statusquery-message> element
  • 18. Sample Status Request 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> <statusquery-message push-id="999999999"> </statusquery-message> </pap>
  • 19. Response Notifications • Sent to the Server URL if specified, none otherwise • Be prepared to handle these – there will be many of them – Quality of Service Levels • Application – Message reached the application • Transport – Message reached the device • None – Fire and forget
  • 20. Listening for Push • User installs mobile application • On first run, mobile application registers with BlackBerry Infrastructure – Creates HTTPS connection to Infrastructure URL • Headers identify PIN and PSID • BlackBerry Infrastructure validates the mobile application • BlackBerry Infrastructure returns pass/fail to mobile application
  • 21. Sample Code: Listening for Push StreamConnection stream; InputStream ins; MDSPushInputStream pushInputStream; //use the port assigned to your application StreamConnectionNotifier notifier = (StreamConnectionNotifier) Connector.open("http://:110"); while( !_stop ) { stream = _notifier.acceptAndOpen(); //blocking operation input = stream.openInputStream(); pushInputStream = new MDSPushInputStream((HttpServerConnection) stream, input); DataBuffer buffer = new DataBuffer(); byte[] data = new byte[ 256 ]; int chunk = 0; while( -1 != (chunk = input.read(data)) ) { buffer.write(data, 0, chunk); } /* … process the data on the DataBuffer ... */ // Signal that we have finished reading. pushInputStream.accept(); }
  • 22. Security • BlackBerry Infrastructure Authentication • Push Initiator is authenticated to the BlackBerry Infrastructure • Push Initiator can only push to its mobile application • 1:1 relationship between Push Initiator and mobile application • Push Initiator can only push to devices registered for their application • Each push request is authenticated to BlackBerry Infrastructure • Unique listening port for each application • BlackBerry Infrastructure does not encrypt data • Expects that payload data will already be encrypted by Push Initiator • Content Provider Authentication • Mobile application should be authenticated to the Push Initiator
  • 23. Reliability • Choose the appropriate QoS for your application • There are tradeoffs for performance and battery life • Be sure to handle all request failures in your application • Result notifications • Your server app must be prepared to handle these, if you request them • Server outages - RIM infrastructure will retry deliveries … for a while • Always provide an unsubscribe option in your device application • Highest reliability can be achieved by application acknowledgement direct to your server
  • 24. Requesting Access • Register at www.blackberry.com/pushapi • Sample code provided on registration approval • Content Provider tests the push service • Given access to the evaluation infrastructure • Research In Motion validates the Content Provider’s client and server-side applications • Ensuring development guidelines are met • Service is moved into production • Once all requirements are met • Only available to ISV Alliance Partners • To become an ISV Alliance partner visit www.blackberry.com/allianceapplication • Contact for service costs
  • 25. Thank You Pratik Sapra – Application Development Specialist