SlideShare uma empresa Scribd logo
1 de 15
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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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'
 

Último

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 DevelopmentsTrustArc
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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 TerraformAndrey Devyatkin
 
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 RobisonAnna Loughnan Colquhoun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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 StreamsRoshan Dwivedi
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
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...apidays
 
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 Scriptwesley chun
 
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 FresherRemote DBA Services
 

Último (20)

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
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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...
 
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
 
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
 

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