A Rack-mountable webservice for managing push notifications
This is still in early stages of development, so proceed with caution when using this in a production application. Any bug reports, feature requests, or general feedback at this point would be greatly appreciated.
Rack::PushNotification
generates API endpoints that can be consumed by iOS apps to register and unregister for push notifications. Along with the registration API, Rack::PushNotification
spawns an admin console that gives you a convenient interface to manage device tokens and compose targeted push notification messages.
token | "ce8be627 2e43e855 16033e24 b4c28922 0eeda487 9c477160 b2545e95 b68b5969" |
alias | [email protected] |
badge | 0 |
locale | en_US |
language | en |
timezone | America/Los_Angeles |
ip_address | 0.0.0.0 |
lat | 37.7716 |
lng | -122.4137 |
tags | ["iPhone OS 6.0", "v1.0", "iPhone"] |
Each device has a token
, which uniquely identifies the app installation on a particular device. This token can be associated with an alias
, which can be a domain-specific piece of identifying information, such as a username or e-mail address. A running badge
count is used to keep track of the badge count to show on the app icon.
A device's locale
& language
can be used to localize outgoing communications to that particular user. Having timezone
information gives you the ability to schedule messages for an exact time of day, to ensure maximum impact (and minimum annoyance). ip_address
as well as lat
and lng
allows you to specifically target users according to their geographic location.
It is strongly recommended that you use Rack::PushNotification
in conjunction with some sort of Rack authentication middleware, so that the administration endpoints are not accessible without some form of credentials.
Rack::PushNotification can be run as Rack middleware or as a single web application. All that is required is a connection to a Postgres database.
require 'bundler'
Bundler.require
Rack::PushNotification::Admin.use Rack::Auth::Basic do |username, password|
[username, password] == ['admin', ENV['ADMIN_CONSOLE_PASSWORD'] || ""]
end
use Rack::PushNotification::Admin, certificate: "/path/to/apn_certificate.pem",
environment: :production
run Rack::PushNotification
An example application can be found in the /example
directory of this repository.
To get the full benefit of Rack::PushNotification
, use the Orbiter library to register for Push Notifications on iOS.
#import "Orbiter.h"
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSURL *serverURL = [NSURL URLWithString:@"http://raging-notification-3556.herokuapp.com/"]
Orbiter *orbiter = [[Orbiter alloc] initWithBaseURL:serverURL credential:nil];
[orbiter registerDeviceToken:deviceToken withAlias:nil success:^(id responseObject) {
NSLog(@"Registration Success: %@", responseObject);
} failure:^(NSError *error) {
NSLog(@"Registration Error: %@", error);
}];
}
Rack::PushNotification
can be deployed to Heroku with the following commands:
$ heroku create
$ heroku credentials:add ADMIN_CONSOLE_PASSWORD="YourPa55wordG0esH3r3"
$ git push heroku master
Mattt Thompson
Rack::PushNotification is available under the MIT license. See the LICENSE file for more info.