Skip to content

Instantly share code, notes, and snippets.

@marshluca
Created March 17, 2011 07:58
Show Gist options
  • Save marshluca/873986 to your computer and use it in GitHub Desktop.
Save marshluca/873986 to your computer and use it in GitHub Desktop.
Apple Push Notification Services
require "rubygems"
require "/Library/Ruby/Gems/1.8/gems/apns-0.9.0/lib/apns"
###################
# Hosts Config
###################
# Push Notification Service:
#
# (default: gateway.sandbox.push.apple.com is)
# Set as below for a production install
# APNS.host = 'gateway.push.apple.com'
APNS.host = 'gateway.sandbox.push.apple.com'
# (default: 2195)
APNS.port = 2195
# Feedback Service:
#
# (default: feedback.sandbox.push.apple.com)
# APNS.feedback_host = 'feedback.push.apple.com'
# APNS.feedback_host = 'feedback.sandbox.push.apple.com'
# (default: 2196)
# APNS.feedback_port = 2196
####################
# Certificate Setup
####################
# Path to the .pem file created earlier
APNS.pem = 'ck.pem'
# Password for decrypting the .pem file, if one was used
APNS.pass = '123456'
####################
# Connection Mgmt
####################
# Cache open connections when sending push notifications
# this will force the gem to keep 1 connection open per
# host/port pair, and reuse it when sending notifications
# (default: false)
# APNS.cache_connections = true
device_token = '150fa6b9 2b1ca0fd 07eaaee9 dd1a4c66 6cae5c69 8ead4057 14594fb4 c618d873'
APNS.send_notification(device_token, 'Hello World!!!!')
APNS.send_notification(device_token, :aps => {:alert => 'Hello iPhone!', :badge => 13, :sound => 'default'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment