forked from PRX/apn_on_rails
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for the apple_hash method
- Loading branch information
Showing
6 changed files
with
110 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,45 @@ | ||
README | ||
======================================================================== | ||
apn_on_rails was developed by: markbates | ||
Apple Push Notification | ||
===================== | ||
|
||
This plugin helps you use the Apple Push Notification system. | ||
|
||
Converting Your Certificate | ||
--------------------------- | ||
|
||
Once you have the certificate from Apple for your application, export your key | ||
and the apple certificate as p12 files. Here is a quick walkthrough on how to do this: | ||
|
||
1. Click the disclosure arrow next to your certificate in Keychain Access and select the certificate and the key. | ||
2. Right click and choose `Export 2 items...`. | ||
3. Choose the p12 format from the drop down and name it `cert.p12`. | ||
|
||
Now covert the p12 file to a pem file: | ||
|
||
$ openssl pkcs12 -in cert.p12 -out apple_push_notification.pem -nodes -clcerts | ||
|
||
Put `apple_push_notification.pem` in config/ | ||
|
||
Installing | ||
---------- | ||
|
||
Simply run the following commands to add apple-push-notification as a submodule to your repo, a plugin to your rails app, and install it. | ||
|
||
$ cd ~/my_rails_app | ||
$ script/plugin install git://github.com/samsoffes/apple_push_notification.git | ||
$ rake apn:migrate | ||
|
||
Example | ||
------- | ||
|
||
*Note: the spaces in `device_token` are optional.* | ||
|
||
$ ./script/console | ||
>> a = ApplePushNotification.new | ||
>> a.device_token = "XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX" | ||
>> a.badge = 5 | ||
>> a.sound = true | ||
>> a.alert = "foobar" | ||
>> a.send_notification | ||
=> nil | ||
|
||
Copyright (c) 2009 Fabien Penso. Released under the MIT license. Modified by [Sam Soffes](http://samsoff.es). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module NotificationFactory | ||
|
||
class << self | ||
|
||
def new(options = {}) | ||
device = APN::Device.first | ||
options = {:device_id => device.id, :sound => 'my_sound.aiff', | ||
:badge => 5, :alert => 'Hello!'}.merge(options) | ||
return APN::Notification.new(options) | ||
end | ||
|
||
def create(options = {}) | ||
notification = NotificationFactory.new(options) | ||
notification.save | ||
return notification | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
NotificationFactory.create | ||
|
||
# t.integer :device_id, :null => false | ||
# t.integer :errors_nb, :default => 0 # used for storing errors from apple feedbacks | ||
# t.string :device_language, :size => 5 # if you don't want to send localized strings | ||
# t.text :payload | ||
# t.string :sound | ||
# t.integer :badge | ||
# t.text :app_data | ||
# t.datetime :sent_at | ||
# t.timestamps |