SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
REST is not enough
Juan Gomez
@_juandg
Using Push Notifications to better support your
mobile clients
What this talk is about
• Brief introduction to push notifications
• Why you need to embrace them
• High level details on how to implement them in
Python
2
What I’m not going to cover
• Implementation on the smartphone side.
• Lots of code.
• Specially production ready code.
• Detailed topics.
3
How many hours of your life have
you spent looking at this webpage?
4
5
6
!
!
!
There has to be
a better way…
Our current model
7
8
Smartphone use around the world
isn’t growing
9
It’s exploding
10
Smartphones are eating the world!
11
Our current model
12
Not very efficient
13
Servers are smart
14
How do we solve this?
15
What’s a Push Notification?
!
• Display a short text message
• Play a brief sound
• iOS: Set a number in a badge on the app’s icon
• Android: Display a banner on the notification bar
16
General architecture
17
PN
Service
Anatomy of a Push Notification
!
{	
	 "aps":	
	 {	
	 	 "alert":	
	 	 {	
	 	 	 "action-loc-key": "Open",	
	 	 	 "body": "Hello, world!"	
	 	 },	
	 	 "badge": 2	
	 }	
}
18
High level comparison
19
Connection
Streaming TCP/IP
Socket
HTTP/XMPP
Security SSL SSL
Content Binary JSON
Max payload 256 bytes 4 kb
Device errors Asynchronous query HTTP/XMPP response
Downside of PNs
• Not reliable
• No guarantee the push will be delivered
• Stale information
• Expirations
20
APPLE PUSH NOTIFICATION
(APN)
21
What you need to get started
• iOS app
• Provisioning profile
• Certificate
• Device tokens
• Payload (a.k.a your messages)
22
Obtaining the certificate
Similar to any other SSL cert
• Generate CSR
• Upload it to Apple
• Link it to your App Id
• Enable Push Notifications
• Generate certificate
23
Obtaining the device token
24
Establishing trust with APNs
25
Best way to do APNs on Python
Use PyAPNS
• It’s on PyPI
• $ pip install apns
• Source Code on Github
• https://github.com/djacobs/PyAPNs
26
Send simple Push with PyAPNs
!
!
!
from apns import APNs, Frame, Payload	
!
apns = APNs(use_sandbox=True, cert_file='cert.pem', 	
key_file='key.pem')
27
Send simple Push with PyAPNs
!
!
!
token_hex = 'some_token'	
payload = Payload(alert="Hello World!", 	
	 	 sound="default", 	
	 	 badge=1)	
apns.gateway_server.send_notification(token_hex, 	 	 	
	 	 	 	 	 	 	 	 	 	 	 	 	 payload)
28
Send multiple PNs with PyAPNs
!
import time	
…	
frame = Frame()!
identifier = 1!
expiry = time.time()+3600!
priority = 10!
frame.add_item('some_token', payload, identifier, 	
	 	 	 	 	 expiry, priority)	
frame.add_item(…)	
frame.add_item(…)	
apns.gateway_server.send_notification_multiple(frame)
29
Scaling your APNs implementation
30
GOOGLE CLOUD MESSAGING
(GCM)
31
What you need to get started
• Android app
• Sender Id
• Application Id (a.k.a Package name)
• Registration Id
• Google User Account
• Sender Auth Token
• Payload (a.k.a your messages)
32
GCM has two implementations
• GCM HTTP
• Uses HTTP POST
• Downstream only
• Easy to implement
• GCM Cloud Connection Server (CCS)
• Based on XMPP (Jabber)
• Two way communication
33
Good way to do GCM on Python
Use SleekXMPP
• It’s on PyPI
• $ pip install sleekxmpp
• Source Code on Github
• https://github.com/fritzy/SleekXMPP
34
Connecting to GCM with SleekXMPP
!
!
from sleekxmpp import ClientXMPP	
xmpp = ClientXMPP('PROJECT_ID@gcm.googleapis.com', 	
	 	 	 	 	 	 'API_KEY')	
xmpp.connect(address=('gcm.googleapis.com', 5235), 	
	 	 	 	 	 use_ssl=True)
35
3RD PARTY ALTERNATIVES
36
Parse
• Acquired by Facebook a year ago.
• Does much more than just Push Notifications
• Cross-platform SDKs
• iOS, Android, Windows Phone, etc.
• Uses a very simple REST API for sending PNs
37
Send simple Push with Parse
!
!
!
!
!
import json,httplib	
connection = httplib.HTTPSConnection('api.parse.com', 443)	
connection.connect()
38
Send simple Push with Parse
!
connection.request('POST', '/1/push', json.dumps({	
       "channels": [ “Giants", “Mets" ],	
       "data": {	
         "alert": "The Giants won against the Mets 2-3."	
       }	
     }), {	
       "X-Parse-Application-Id": "${APPLICATION_ID}",	
       "X-Parse-REST-API-Key": "${REST_API_KEY}",	
       "Content-Type": "application/json"	
     })	
result = json.loads(connection.getresponse().read())
39
Downsides of Parse
• No Official Python SDK
• 3rd party “recommended” SDK on Github
• Issues with their Mobile SDK
• Specifically on Android
• They’re working through them
40
Urban Airship
• Push is still their main product
• Moving into mobile marketing and payments.
• Based out of Portland, OR
• Simple REST API
• Cross-platform SDKs
• iOS, Android, Blackberry, etc.
• Official Python SDK
41
Send simple Push with UA
!
!
import urbanairship as ua	
airship = ua.Airship('application_key','master_secret')	
push = airship.create_push()	
push.audience = ua.or_(ua.alias(‘adam'),	
	 	 ua.device_token('some_token'))	
push.notification = ua.notification(alert='Hello')	
push.device_types = ua.all_	
push.send()
42
SUMMARY
43
Summary
• Mobile is eating the world.
• Push Notification will make your service smarter.
• Using Python for Push Notifications is easy.
44
Thank You!
Twitter: @_juandg
Email: jgomez@eventbrite.com
Lanyrd: lanyrd.com/profile/juandg/

Más contenido relacionado

Destacado

Restful Asynchronous Notification
Restful Asynchronous NotificationRestful Asynchronous Notification
Restful Asynchronous NotificationMichael Koster
 
Push-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesPush-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesCesare Pautasso
 
Beyond REST? Building data services with XMPP
Beyond REST? Building data services with XMPPBeyond REST? Building data services with XMPP
Beyond REST? Building data services with XMPPKellan
 
Stardust - Open Source BPMS for the Financial Industry
Stardust - Open Source BPMS for the Financial IndustryStardust - Open Source BPMS for the Financial Industry
Stardust - Open Source BPMS for the Financial IndustryMarc Gille
 
My rails way
My rails wayMy rails way
My rails waywildjcrt
 
Push notification salesforce
Push notification salesforcePush notification salesforce
Push notification salesforceSon Nguyen
 
Rails 4 & server sent events
Rails 4 & server sent eventsRails 4 & server sent events
Rails 4 & server sent eventsPiotr Karbownik
 
Example Mobile Push Notification Service in Rails
Example Mobile Push Notification Service in RailsExample Mobile Push Notification Service in Rails
Example Mobile Push Notification Service in RailsMo Omer
 
Don't call us - we'll push - cross tier push architecture (JavaOne 2011)
Don't call us - we'll push - cross tier push architecture (JavaOne 2011)Don't call us - we'll push - cross tier push architecture (JavaOne 2011)
Don't call us - we'll push - cross tier push architecture (JavaOne 2011)Lucas Jellema
 
Practical Push Notifications Seminar
Practical Push Notifications SeminarPractical Push Notifications Seminar
Practical Push Notifications SeminarXamarin
 
Push notifications
Push notificationsPush notifications
Push notificationsDale Lane
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPPJack Moffitt
 
Gearing up for mobile push notifications
Gearing up for mobile push notificationsGearing up for mobile push notifications
Gearing up for mobile push notificationsKeith Moore
 
A Context and User Aware Smart Notification System
A Context and User Aware Smart Notification SystemA Context and User Aware Smart Notification System
A Context and User Aware Smart Notification SystemTeodoro Montanaro
 
생활코딩 oauth 소개
생활코딩 oauth 소개생활코딩 oauth 소개
생활코딩 oauth 소개Binseop Ko
 

Destacado (20)

Restful Asynchronous Notification
Restful Asynchronous NotificationRestful Asynchronous Notification
Restful Asynchronous Notification
 
Push-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesPush-Enabling RESTful Business Processes
Push-Enabling RESTful Business Processes
 
RESTful Notification
RESTful NotificationRESTful Notification
RESTful Notification
 
Beyond REST? Building data services with XMPP
Beyond REST? Building data services with XMPPBeyond REST? Building data services with XMPP
Beyond REST? Building data services with XMPP
 
Stardust - Open Source BPMS for the Financial Industry
Stardust - Open Source BPMS for the Financial IndustryStardust - Open Source BPMS for the Financial Industry
Stardust - Open Source BPMS for the Financial Industry
 
Rails notification
Rails notificationRails notification
Rails notification
 
My rails way
My rails wayMy rails way
My rails way
 
Push notification salesforce
Push notification salesforcePush notification salesforce
Push notification salesforce
 
Rails 4 & server sent events
Rails 4 & server sent eventsRails 4 & server sent events
Rails 4 & server sent events
 
Example Mobile Push Notification Service in Rails
Example Mobile Push Notification Service in RailsExample Mobile Push Notification Service in Rails
Example Mobile Push Notification Service in Rails
 
Don't call us - we'll push - cross tier push architecture (JavaOne 2011)
Don't call us - we'll push - cross tier push architecture (JavaOne 2011)Don't call us - we'll push - cross tier push architecture (JavaOne 2011)
Don't call us - we'll push - cross tier push architecture (JavaOne 2011)
 
Php push notifications
Php push notificationsPhp push notifications
Php push notifications
 
Practical Push Notifications Seminar
Practical Push Notifications SeminarPractical Push Notifications Seminar
Practical Push Notifications Seminar
 
Action cable
Action cableAction cable
Action cable
 
Apple push notification service
Apple push notification serviceApple push notification service
Apple push notification service
 
Push notifications
Push notificationsPush notifications
Push notifications
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPP
 
Gearing up for mobile push notifications
Gearing up for mobile push notificationsGearing up for mobile push notifications
Gearing up for mobile push notifications
 
A Context and User Aware Smart Notification System
A Context and User Aware Smart Notification SystemA Context and User Aware Smart Notification System
A Context and User Aware Smart Notification System
 
생활코딩 oauth 소개
생활코딩 oauth 소개생활코딩 oauth 소개
생활코딩 oauth 소개
 

Similar a REST is not enough: Using Push Notifications to better support your mobile clients

用Serverless技術快速開發line聊天機器人
用Serverless技術快速開發line聊天機器人用Serverless技術快速開發line聊天機器人
用Serverless技術快速開發line聊天機器人Kevin Luo
 
Fastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsFastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsSarath C
 
Continous Integration for iOS Projects
Continous Integration for iOS ProjectsContinous Integration for iOS Projects
Continous Integration for iOS ProjectsCiprian Redinciuc
 
Continuous integration by Rémy Virin
Continuous integration by Rémy VirinContinuous integration by Rémy Virin
Continuous integration by Rémy VirinCocoaHeads France
 
Free Mongo on OpenShift
Free Mongo on OpenShiftFree Mongo on OpenShift
Free Mongo on OpenShiftSteven Pousty
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
 
ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2Jürgen Gutsch
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without InterferenceTony Tam
 
ChatOps Workshop
ChatOps WorkshopChatOps Workshop
ChatOps WorkshopTessa Mero
 
OpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red HatsOpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red HatsMark Atwood
 
Sonian, Open Source and Sensu
Sonian, Open Source and SensuSonian, Open Source and Sensu
Sonian, Open Source and SensuPete Cheslock
 
Programming for the Internet of Things
Programming for the Internet of ThingsProgramming for the Internet of Things
Programming for the Internet of ThingsKinoma
 
SplunkLive! Developer Session
SplunkLive! Developer SessionSplunkLive! Developer Session
SplunkLive! Developer SessionSplunk
 
OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012Steven Pousty
 
Distributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromqDistributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromqRuben Tan
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"DataArt
 
Oscon presentation
Oscon presentationOscon presentation
Oscon presentationgarrettmoon
 
Automating SDK generation - London Mobile Forum 2.0
Automating SDK generation - London Mobile Forum 2.0Automating SDK generation - London Mobile Forum 2.0
Automating SDK generation - London Mobile Forum 2.0Thong Nguyen
 
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...NCCOMMS
 
Node in Production at Aviary
Node in Production at AviaryNode in Production at Aviary
Node in Production at AviaryAviary
 

Similar a REST is not enough: Using Push Notifications to better support your mobile clients (20)

用Serverless技術快速開發line聊天機器人
用Serverless技術快速開發line聊天機器人用Serverless技術快速開發line聊天機器人
用Serverless技術快速開發line聊天機器人
 
Fastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsFastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS Apps
 
Continous Integration for iOS Projects
Continous Integration for iOS ProjectsContinous Integration for iOS Projects
Continous Integration for iOS Projects
 
Continuous integration by Rémy Virin
Continuous integration by Rémy VirinContinuous integration by Rémy Virin
Continuous integration by Rémy Virin
 
Free Mongo on OpenShift
Free Mongo on OpenShiftFree Mongo on OpenShift
Free Mongo on OpenShift
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2ASP.NET 5 on the Raspberry PI 2
ASP.NET 5 on the Raspberry PI 2
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
ChatOps Workshop
ChatOps WorkshopChatOps Workshop
ChatOps Workshop
 
OpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red HatsOpenShift Origin: Build a PaaS Just Like Red Hats
OpenShift Origin: Build a PaaS Just Like Red Hats
 
Sonian, Open Source and Sensu
Sonian, Open Source and SensuSonian, Open Source and Sensu
Sonian, Open Source and Sensu
 
Programming for the Internet of Things
Programming for the Internet of ThingsProgramming for the Internet of Things
Programming for the Internet of Things
 
SplunkLive! Developer Session
SplunkLive! Developer SessionSplunkLive! Developer Session
SplunkLive! Developer Session
 
OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012
 
Distributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromqDistributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromq
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"
 
Oscon presentation
Oscon presentationOscon presentation
Oscon presentation
 
Automating SDK generation - London Mobile Forum 2.0
Automating SDK generation - London Mobile Forum 2.0Automating SDK generation - London Mobile Forum 2.0
Automating SDK generation - London Mobile Forum 2.0
 
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
 
Node in Production at Aviary
Node in Production at AviaryNode in Production at Aviary
Node in Production at Aviary
 

Más de Juan Gomez

App Indexing: Blurring the Lines Between Your Website and App
App Indexing: Blurring the Lines Between Your Website and AppApp Indexing: Blurring the Lines Between Your Website and App
App Indexing: Blurring the Lines Between Your Website and AppJuan Gomez
 
Beating Android Fragmentation
Beating Android FragmentationBeating Android Fragmentation
Beating Android FragmentationJuan Gomez
 
Effective Android Messaging
Effective Android MessagingEffective Android Messaging
Effective Android MessagingJuan Gomez
 
Teach your kids how to program with Python and the Raspberry Pi
Teach your kids how to program with Python and the Raspberry PiTeach your kids how to program with Python and the Raspberry Pi
Teach your kids how to program with Python and the Raspberry PiJuan Gomez
 
Android Scripting
Android ScriptingAndroid Scripting
Android ScriptingJuan Gomez
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011Juan Gomez
 

Más de Juan Gomez (6)

App Indexing: Blurring the Lines Between Your Website and App
App Indexing: Blurring the Lines Between Your Website and AppApp Indexing: Blurring the Lines Between Your Website and App
App Indexing: Blurring the Lines Between Your Website and App
 
Beating Android Fragmentation
Beating Android FragmentationBeating Android Fragmentation
Beating Android Fragmentation
 
Effective Android Messaging
Effective Android MessagingEffective Android Messaging
Effective Android Messaging
 
Teach your kids how to program with Python and the Raspberry Pi
Teach your kids how to program with Python and the Raspberry PiTeach your kids how to program with Python and the Raspberry Pi
Teach your kids how to program with Python and the Raspberry Pi
 
Android Scripting
Android ScriptingAndroid Scripting
Android Scripting
 
Gae icc fall2011
Gae icc fall2011Gae icc fall2011
Gae icc fall2011
 

Último

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 

Último (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

REST is not enough: Using Push Notifications to better support your mobile clients

  • 1. REST is not enough Juan Gomez @_juandg Using Push Notifications to better support your mobile clients
  • 2. What this talk is about • Brief introduction to push notifications • Why you need to embrace them • High level details on how to implement them in Python 2
  • 3. What I’m not going to cover • Implementation on the smartphone side. • Lots of code. • Specially production ready code. • Detailed topics. 3
  • 4. How many hours of your life have you spent looking at this webpage? 4
  • 5. 5
  • 6. 6 ! ! ! There has to be a better way…
  • 8. 8
  • 9. Smartphone use around the world isn’t growing 9
  • 11. Smartphones are eating the world! 11
  • 15. How do we solve this? 15
  • 16. What’s a Push Notification? ! • Display a short text message • Play a brief sound • iOS: Set a number in a badge on the app’s icon • Android: Display a banner on the notification bar 16
  • 18. Anatomy of a Push Notification ! { "aps": { "alert": { "action-loc-key": "Open", "body": "Hello, world!" }, "badge": 2 } } 18
  • 19. High level comparison 19 Connection Streaming TCP/IP Socket HTTP/XMPP Security SSL SSL Content Binary JSON Max payload 256 bytes 4 kb Device errors Asynchronous query HTTP/XMPP response
  • 20. Downside of PNs • Not reliable • No guarantee the push will be delivered • Stale information • Expirations 20
  • 22. What you need to get started • iOS app • Provisioning profile • Certificate • Device tokens • Payload (a.k.a your messages) 22
  • 23. Obtaining the certificate Similar to any other SSL cert • Generate CSR • Upload it to Apple • Link it to your App Id • Enable Push Notifications • Generate certificate 23
  • 26. Best way to do APNs on Python Use PyAPNS • It’s on PyPI • $ pip install apns • Source Code on Github • https://github.com/djacobs/PyAPNs 26
  • 27. Send simple Push with PyAPNs ! ! ! from apns import APNs, Frame, Payload ! apns = APNs(use_sandbox=True, cert_file='cert.pem', key_file='key.pem') 27
  • 28. Send simple Push with PyAPNs ! ! ! token_hex = 'some_token' payload = Payload(alert="Hello World!", sound="default", badge=1) apns.gateway_server.send_notification(token_hex, payload) 28
  • 29. Send multiple PNs with PyAPNs ! import time … frame = Frame()! identifier = 1! expiry = time.time()+3600! priority = 10! frame.add_item('some_token', payload, identifier, expiry, priority) frame.add_item(…) frame.add_item(…) apns.gateway_server.send_notification_multiple(frame) 29
  • 30. Scaling your APNs implementation 30
  • 32. What you need to get started • Android app • Sender Id • Application Id (a.k.a Package name) • Registration Id • Google User Account • Sender Auth Token • Payload (a.k.a your messages) 32
  • 33. GCM has two implementations • GCM HTTP • Uses HTTP POST • Downstream only • Easy to implement • GCM Cloud Connection Server (CCS) • Based on XMPP (Jabber) • Two way communication 33
  • 34. Good way to do GCM on Python Use SleekXMPP • It’s on PyPI • $ pip install sleekxmpp • Source Code on Github • https://github.com/fritzy/SleekXMPP 34
  • 35. Connecting to GCM with SleekXMPP ! ! from sleekxmpp import ClientXMPP xmpp = ClientXMPP('PROJECT_ID@gcm.googleapis.com', 'API_KEY') xmpp.connect(address=('gcm.googleapis.com', 5235), use_ssl=True) 35
  • 37. Parse • Acquired by Facebook a year ago. • Does much more than just Push Notifications • Cross-platform SDKs • iOS, Android, Windows Phone, etc. • Uses a very simple REST API for sending PNs 37
  • 38. Send simple Push with Parse ! ! ! ! ! import json,httplib connection = httplib.HTTPSConnection('api.parse.com', 443) connection.connect() 38
  • 39. Send simple Push with Parse ! connection.request('POST', '/1/push', json.dumps({        "channels": [ “Giants", “Mets" ],        "data": {          "alert": "The Giants won against the Mets 2-3."        }      }), {        "X-Parse-Application-Id": "${APPLICATION_ID}",        "X-Parse-REST-API-Key": "${REST_API_KEY}",        "Content-Type": "application/json"      }) result = json.loads(connection.getresponse().read()) 39
  • 40. Downsides of Parse • No Official Python SDK • 3rd party “recommended” SDK on Github • Issues with their Mobile SDK • Specifically on Android • They’re working through them 40
  • 41. Urban Airship • Push is still their main product • Moving into mobile marketing and payments. • Based out of Portland, OR • Simple REST API • Cross-platform SDKs • iOS, Android, Blackberry, etc. • Official Python SDK 41
  • 42. Send simple Push with UA ! ! import urbanairship as ua airship = ua.Airship('application_key','master_secret') push = airship.create_push() push.audience = ua.or_(ua.alias(‘adam'), ua.device_token('some_token')) push.notification = ua.notification(alert='Hello') push.device_types = ua.all_ push.send() 42
  • 44. Summary • Mobile is eating the world. • Push Notification will make your service smarter. • Using Python for Push Notifications is easy. 44
  • 45. Thank You! Twitter: @_juandg Email: jgomez@eventbrite.com Lanyrd: lanyrd.com/profile/juandg/