SlideShare a Scribd company logo
How to build a server and a iPhone client
   application using the Apple Push
         Notification Service
            2009/7/21 @ actindi
               Shu MASUDA
2
Apple Push Notification Service (APNs)
What is the Apple Push Notification Service?



 ‣ iPhone OS 3.0
 ‣                          3

   • Alert
   • Badge
   • Sound
 ‣
3
Client Implementation Overview

 ★ APNs
  •   UIApplication   registerForRemoteNotificationTypes:



  •   UIApplication   application:didRegisterForRemoteNotificationsWithDeviceToken:
                                                         Device Token


 ★ APNs
  •   UIApplicationDelegate    application:didReceiveRemoteNotification:



  •   UIApplication Delegate   applicationDidFinishLaunching:
4
Client Implementation




 •           Xcode
5
Server Implementation Overview


 1. App ID


 2.

 3. Interface APNS


 4.          Ruby
6
Generating App ID




                       Bundle
     Identifier   ”*”
6
Generating App ID




     Enable for Apple Push Notification service
6
Generating App ID




     Enable for Apple Push Notification service
7
Generating Key
 1.   p12     pem

      •    openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in
           apns-dev-cert.p12

      •    openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-
           key.p12
 2.   1.

      •    openssl rsa -in apns-dev-key.pem -out apns-dev-key-
           noenc.pem
 3.

      •    cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem
 4.   OpenSSL

      •    openssl s_client -connect gateway.sandbox.push.apple.com:
           2195 -prexit -state -cert apns-dev-cert.pem -key apns-dev-
           key-noenc.pem
8
Creating the Push Notification Interface

 • Binary format of the push notification interface



 •              (payload)   JSON
  {
      “aps”: {
        “alert”: “You’ve got a mail!”,
        “badge”: 1,
        “sound”: “default”
      }
  }
9
Implementation in Ruby
 ★ Ruby

  •   pack? unpack?? or ... ???

  •
10
Implementation in Ruby
#! /usr/bin/env ruby
# -*- encoding: utf-8 -*-

require 'socket'
require 'openssl'

socket = TCPSocket.new('gateway.sandbox.push.apple.com', 2195)

context = OpenSSL::SSL::SSLContext.new('SSLv3')
context.cert = OpenSSL::X509::Certificate.new(File.read('apns-dev.pem'))
context.key = OpenSSL::PKey::RSA.new(File.read('apns-dev-key-noenc.pem'))

ssl = OpenSSL::SSL::SSLSocket.new(socket, context)
ssl.connect

device_token = ['XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX']
payload = <<-EOS
{
  "aps": {
     "alert": "#{alert}",
     "badge": 2,
     “sound”: “default”
  }
}
EOS

(message = []) << ['0'].pack('H') << [32].pack('n') << device_token.pack('H*') << [payload.size].pack('n') << payload
ssl.write(message.join(''))

ssl.close
socket.close
It’s time to Demo!
12


★
•   Miss Piggy

•   Catherine       Miss Piggy

•   Mr. Kermit      iPhone


★
Miss Piggy                 Cathy (Catherine)
                                                  Miss Piggy
Miss Piggy Cathy                                                     Kermit


       Miss Piggy                   Kermit iPhone Push Notification
13
References


 •   Apple Push Notification Service Programming Guide
     http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/
     RemoteNotificationsPG/Introduction/Introduction.html

 •   How to build an Apple Push Notification provider server (tutorial) « Boxed Ice Blog
     http://blog.boxedice.com/2009/07/10/how-to-build-an-apple-push-notification-provider-
     server-tutorial/

 •   Ruby                           - pack
     http://www.ruby-lang.org/ja/man/html/
     pack_A5C6A5F3A5D7A5ECA1BCA5C8CAB8BBFACEF3.html

 •   SSL - 2008-01-03 -
     http://d.hatena.ne.jp/shinichiro_h/20080103#1199305204

More Related Content

What's hot

Otra forma de hacer aplicaciones de telefonía
Otra forma de hacer aplicaciones de telefoníaOtra forma de hacer aplicaciones de telefonía
Otra forma de hacer aplicaciones de telefoníaMartin Perez
 
Tropo Presentation for TADHack
Tropo Presentation for TADHackTropo Presentation for TADHack
Tropo Presentation for TADHackAlan Quayle
 
Connecting RubyMotion with Hardware - Rubymotion #Inspect 2014
Connecting RubyMotion with Hardware - Rubymotion #Inspect 2014Connecting RubyMotion with Hardware - Rubymotion #Inspect 2014
Connecting RubyMotion with Hardware - Rubymotion #Inspect 2014Mark Villacampa
 
Tropo: Telephony in the Cloud
Tropo: Telephony in the CloudTropo: Telephony in the Cloud
Tropo: Telephony in the CloudWes Gamble
 
Irv Shapiro's Presentation at eComm 2009
Irv Shapiro's Presentation at eComm 2009Irv Shapiro's Presentation at eComm 2009
Irv Shapiro's Presentation at eComm 2009eCommConf
 
Appdome & OWASP Keynote Presentation | API World 2019
Appdome & OWASP Keynote Presentation | API World 2019Appdome & OWASP Keynote Presentation | API World 2019
Appdome & OWASP Keynote Presentation | API World 2019Anne Smith
 
Developing powerful mobile apps with Xamarin.Essentials
Developing powerful mobile apps with Xamarin.EssentialsDeveloping powerful mobile apps with Xamarin.Essentials
Developing powerful mobile apps with Xamarin.EssentialsLuis Beltran
 
Speech Recognition as a User Interface
Speech Recognition as a User InterfaceSpeech Recognition as a User Interface
Speech Recognition as a User InterfaceJared Sheehan
 

What's hot (9)

Otra forma de hacer aplicaciones de telefonía
Otra forma de hacer aplicaciones de telefoníaOtra forma de hacer aplicaciones de telefonía
Otra forma de hacer aplicaciones de telefonía
 
Tropo Presentation for TADHack
Tropo Presentation for TADHackTropo Presentation for TADHack
Tropo Presentation for TADHack
 
Connecting RubyMotion with Hardware - Rubymotion #Inspect 2014
Connecting RubyMotion with Hardware - Rubymotion #Inspect 2014Connecting RubyMotion with Hardware - Rubymotion #Inspect 2014
Connecting RubyMotion with Hardware - Rubymotion #Inspect 2014
 
Tropo: Telephony in the Cloud
Tropo: Telephony in the CloudTropo: Telephony in the Cloud
Tropo: Telephony in the Cloud
 
Irv Shapiro's Presentation at eComm 2009
Irv Shapiro's Presentation at eComm 2009Irv Shapiro's Presentation at eComm 2009
Irv Shapiro's Presentation at eComm 2009
 
Appdome & OWASP Keynote Presentation | API World 2019
Appdome & OWASP Keynote Presentation | API World 2019Appdome & OWASP Keynote Presentation | API World 2019
Appdome & OWASP Keynote Presentation | API World 2019
 
Developing powerful mobile apps with Xamarin.Essentials
Developing powerful mobile apps with Xamarin.EssentialsDeveloping powerful mobile apps with Xamarin.Essentials
Developing powerful mobile apps with Xamarin.Essentials
 
Appium
AppiumAppium
Appium
 
Speech Recognition as a User Interface
Speech Recognition as a User InterfaceSpeech Recognition as a User Interface
Speech Recognition as a User Interface
 

Similar to How to build a server and a iPhone client application using the Apple Push Notification Service

Travis and fastlane
Travis and fastlaneTravis and fastlane
Travis and fastlaneSteven Shen
 
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesChris Bailey
 
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesNode Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesChris Bailey
 
Get step-by-step instructions on implementing notifications in your apps.
Get step-by-step instructions on implementing notifications in your apps.Get step-by-step instructions on implementing notifications in your apps.
Get step-by-step instructions on implementing notifications in your apps.Jigar Maheshwari
 
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...MindShare_kk
 
Build A Cloud Day London - Introduction
Build A Cloud Day London - IntroductionBuild A Cloud Day London - Introduction
Build A Cloud Day London - IntroductionShapeBlue
 
Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Kevin Munc
 
Codecoon - A technical Case Study
Codecoon - A technical Case StudyCodecoon - A technical Case Study
Codecoon - A technical Case StudyMichael Lihs
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
Python in the serverless era (PyCon 2017)
Python in the serverless era (PyCon 2017)Python in the serverless era (PyCon 2017)
Python in the serverless era (PyCon 2017)Benny Bauer
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"Volker Linz
 
Everything ruby
Everything rubyEverything ruby
Everything rubyajeygore
 
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...NGINX, Inc.
 
Automação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsAutomação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsRaul Leite
 
Building an ActionScript Game Server with over 15,000 Concurrent Connections
Building an ActionScript Game Server with over 15,000 Concurrent ConnectionsBuilding an ActionScript Game Server with over 15,000 Concurrent Connections
Building an ActionScript Game Server with over 15,000 Concurrent Connections Renaun Erickson
 
Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAkshaya Mahapatra
 
Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Jen Andre
 

Similar to How to build a server and a iPhone client application using the Apple Push Notification Service (20)

Travis and fastlane
Travis and fastlaneTravis and fastlane
Travis and fastlane
 
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
 
Aws(sns)
Aws(sns)Aws(sns)
Aws(sns)
 
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesNode Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
 
Get step-by-step instructions on implementing notifications in your apps.
Get step-by-step instructions on implementing notifications in your apps.Get step-by-step instructions on implementing notifications in your apps.
Get step-by-step instructions on implementing notifications in your apps.
 
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
BlackHat EU 2012 - Zhenhua Liu - Breeding Sandworms: How To Fuzz Your Way Out...
 
Build A Cloud Day London - Introduction
Build A Cloud Day London - IntroductionBuild A Cloud Day London - Introduction
Build A Cloud Day London - Introduction
 
Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013
 
Codecoon - A technical Case Study
Codecoon - A technical Case StudyCodecoon - A technical Case Study
Codecoon - A technical Case Study
 
Docker In Bank Unrated
Docker In Bank UnratedDocker In Bank Unrated
Docker In Bank Unrated
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Python in the serverless era (PyCon 2017)
Python in the serverless era (PyCon 2017)Python in the serverless era (PyCon 2017)
Python in the serverless era (PyCon 2017)
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"
 
Everything ruby
Everything rubyEverything ruby
Everything ruby
 
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
 
Automação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsAutomação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOps
 
Building an ActionScript Game Server with over 15,000 Concurrent Connections
Building an ActionScript Game Server with over 15,000 Concurrent ConnectionsBuilding an ActionScript Game Server with over 15,000 Concurrent Connections
Building an ActionScript Game Server with over 15,000 Concurrent Connections
 
Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps Approach
 
CI and CD
CI and CDCI and CD
CI and CD
 
Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'
 

Recently uploaded

IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Alison B. Lowndes
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsPaul Groth
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 

Recently uploaded (20)

IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 

How to build a server and a iPhone client application using the Apple Push Notification Service

  • 1. How to build a server and a iPhone client application using the Apple Push Notification Service 2009/7/21 @ actindi Shu MASUDA
  • 2. 2 Apple Push Notification Service (APNs) What is the Apple Push Notification Service? ‣ iPhone OS 3.0 ‣ 3 • Alert • Badge • Sound ‣
  • 3. 3 Client Implementation Overview ★ APNs • UIApplication registerForRemoteNotificationTypes: • UIApplication application:didRegisterForRemoteNotificationsWithDeviceToken: Device Token ★ APNs • UIApplicationDelegate application:didReceiveRemoteNotification: • UIApplication Delegate applicationDidFinishLaunching:
  • 5. 5 Server Implementation Overview 1. App ID 2. 3. Interface APNS 4. Ruby
  • 6. 6 Generating App ID Bundle Identifier ”*”
  • 7. 6 Generating App ID Enable for Apple Push Notification service
  • 8. 6 Generating App ID Enable for Apple Push Notification service
  • 9. 7 Generating Key 1. p12 pem • openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12 • openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev- key.p12 2. 1. • openssl rsa -in apns-dev-key.pem -out apns-dev-key- noenc.pem 3. • cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem 4. OpenSSL • openssl s_client -connect gateway.sandbox.push.apple.com: 2195 -prexit -state -cert apns-dev-cert.pem -key apns-dev- key-noenc.pem
  • 10. 8 Creating the Push Notification Interface • Binary format of the push notification interface • (payload) JSON { “aps”: { “alert”: “You’ve got a mail!”, “badge”: 1, “sound”: “default” } }
  • 11. 9 Implementation in Ruby ★ Ruby • pack? unpack?? or ... ??? •
  • 12. 10 Implementation in Ruby #! /usr/bin/env ruby # -*- encoding: utf-8 -*- require 'socket' require 'openssl' socket = TCPSocket.new('gateway.sandbox.push.apple.com', 2195) context = OpenSSL::SSL::SSLContext.new('SSLv3') context.cert = OpenSSL::X509::Certificate.new(File.read('apns-dev.pem')) context.key = OpenSSL::PKey::RSA.new(File.read('apns-dev-key-noenc.pem')) ssl = OpenSSL::SSL::SSLSocket.new(socket, context) ssl.connect device_token = ['XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'] payload = <<-EOS { "aps": { "alert": "#{alert}", "badge": 2, “sound”: “default” } } EOS (message = []) << ['0'].pack('H') << [32].pack('n') << device_token.pack('H*') << [payload.size].pack('n') << payload ssl.write(message.join('')) ssl.close socket.close
  • 13. It’s time to Demo!
  • 14. 12 ★ • Miss Piggy • Catherine Miss Piggy • Mr. Kermit iPhone ★ Miss Piggy Cathy (Catherine) Miss Piggy Miss Piggy Cathy Kermit Miss Piggy Kermit iPhone Push Notification
  • 15. 13 References • Apple Push Notification Service Programming Guide http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/ RemoteNotificationsPG/Introduction/Introduction.html • How to build an Apple Push Notification provider server (tutorial) « Boxed Ice Blog http://blog.boxedice.com/2009/07/10/how-to-build-an-apple-push-notification-provider- server-tutorial/ • Ruby - pack http://www.ruby-lang.org/ja/man/html/ pack_A5C6A5F3A5D7A5ECA1BCA5C8CAB8BBFACEF3.html • SSL - 2008-01-03 - http://d.hatena.ne.jp/shinichiro_h/20080103#1199305204