0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A simple Ruby framework for sending push notifications and receiving feedback using the Apple Push Notification service
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 2.13.0

Runtime

~> 1.8.1
~> 2.0.2
 Project Readme

This project is unmaintained. We recommend using a library compatible with Apple's newer HTTP/2-based API, such as apnotic.

ApnsDispatch

A simple Ruby framework for sending push notifications and receiving feedback using the Apple Push Notification service

Installation

Add this line to your application's Gemfile:

gem 'apns_dispatch'

And then execute:

$ bundle

Or install it yourself as:

$ gem install apns_dispatch

Sending Notifications

connection = ApnsConnection.new(CERTIFICATE, production: true)
ApnNotification.new(connection, DEVICE_TOKEN, 'a message to a device').send_notification

Checking the Feedback Service

Apple recommends periodically checking their feedback service for device tokens that have failed delivery. The feedback service also returns the time of the failure. If a device token was registered before the failure time, it should be removed from your system.

connection = ApnsConnection.new(CERTIFICATE, production: true, feedback: true)
ApnFeedback.new(connection).failed_device_tokens.each do |device_token, failure_time|
    # Delete this device token from your system, if the registration time is before failure_time
end

Connection Pooling

If notifications are sent frequently, latency will be improved by reusing connections to the Push Notification service. ApnsDispatch also provides connection pooling:

# Initiates a new connection to the APNs
connection = ApnsConnectionPool.connection(CERTIFICATE, production: true)

# This will return the same connection, rather than initiating a new one
connection = ApnsConnectionPool.connection(CERTIFICATE, production: true)

Requirements

apns_dispatch requires Ruby 1.9+.

License

apns_dispatch is written by Costa Walcott, and is Copyright 2012 SCVNGR, Inc. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.