Project

apple-push

0.0
No commit activity in last 3 years
No release in over 3 years
ApplePush is a very simple implementation of the APNS (Apple Push Notification Service) protocol. It differs from the APNS gem by being able to push to different iOS apps from the same Ruby application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

> 1.0.0
 Project Readme

ApplePush

ApplePush is a very simple implementation of the APNS (Apple Push Notification Service) protocol. It differs from the APNS gem by being able to push to different iOS apps from the same Ruby application.

Setup

$ gem install apple-push

require 'apple-push'
ApplePush.host = 'gateway.push.apple.com' 
ApplePush.port = 2195

Creating a PEM certificate

In Keychain access export your certificate as a p12. Then run the following command to convert it to a .pem

openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts

Then store the PEM data in your database or in a file.

Example usage

ApplePush.send_notification(pem, device_token, 'Hello, world!')
ApplePush.send_notification(pem, device_token, :alert => 'Hello, world!', :badge => 1, :sound => 'default')
ApplePush.send_notification(pem, device_token, :alert => 'Hello, world!', :badge => 1, :sound => 'default', :other => { :foo => 'bar' })

The pem parameter can either be the path to a .pem file or the PEM data it self, retrieved from a database for example. If the PEM certificate is encrypted with a password you should pass an array with the pem and the password instead of just the pem.

The device_token can either be binary data, or Base64 encoded.

Author

Created by Niklas Holmgren (niklas@sutajio.se) and released under the MIT license.