-
Notifications
You must be signed in to change notification settings - Fork 10
/
README
96 lines (69 loc) · 2.33 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
===================
URBAN AIRSHIP ON RAILS
===================
Borrowed Liberally from APN on Rails Gem but designed to interface with urbanairship for simplicity, ease of use, and speedy deployment of push notifications
uses identical data schema to APN.. perhaps allowing future upgrade to APN
=======
DEPENDENCIES
=======
requires JSON gem
AASM
=======
HOW TO INSTALL
=======
ruby script/plugin install git://github.com/rickerbh/urbanairship_on_rails.git
=======
HOW TO CONFIGURE
=======
=====
Create an initializer named urbanairship.rb with the following content
require File.dirname(__FILE__) + '/../../vendor/plugins/urbanairship_on_rails/lib/urbanairship_on_rails/libs/config'
UA::Config::app_key = 'YOUR_APP_KEY'
UA::Config::app_secret = 'YOUR_APP_SECRET'
UA::Config::push_secret = 'YOUR_PUSH_SECRET'
UA::Config::push_host = 'go.urbanairship.com'
UA::Config::push_port = '443'
=====
Create User => Device relationship
belongs_to :device, :class_name=>"APN::Device"
=====
Set up a daily cron job to clean out inactive device registrations
rake apn:feedback or
script/runner APN:Feedback.create().run
Set up a cron job to push and manage notifications
rake apn:push or
script/runner APN::Notification.process_pending
=======
API CALLS and current support level
=======
REGISTRATION
APN::Device.register => HTTP PUT to /api/device_tokens/<device_token>
APN::Device.read => HTTP GET to /api/device_tokens/<device_token>
APN::Device.unregister => HTTP DELETE to /api/device_tokens/<device_token>
PUSH
APN::Notifcation.push => HTTP POST to /api/push/
BATCH PUSH
NOT YET SUPPORTED
BROADCAST
NOT YET SUPPORTED
FEEDBACK SERVICE
APN::Feedback.push( => HTTP GET to /api/device_tokens/feedback/?since=<timestamp>
STATISTICS
NOT YET SUPPORTED
=======
Example
=======
To Create and register a device
user.device.create(:token => "token_from_device")
user.device.register(options)
To Read device and tags
user.device.read
To unregister a device
user.device.unregister
To destroy device record (and unregister)
user.device.destroy
To create push notification
user.device.create_notification.create(:badge=>'', :alert=>'', :sound=>'')
To immediately push a notification
user.device.notifications.last.push
Copyright (c) 2009 [Russell Sherman([email protected])], released under the MIT license