rpush 1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +99 -0
- data/LICENSE +7 -0
- data/README.md +189 -0
- data/bin/rpush +36 -0
- data/config/database.yml +44 -0
- data/lib/generators/rpush_generator.rb +44 -0
- data/lib/generators/templates/add_adm.rb +23 -0
- data/lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb +9 -0
- data/lib/generators/templates/add_app_to_rapns.rb +11 -0
- data/lib/generators/templates/add_fail_after_to_rpush_notifications.rb +9 -0
- data/lib/generators/templates/add_gcm.rb +102 -0
- data/lib/generators/templates/add_rpush.rb +349 -0
- data/lib/generators/templates/add_wpns.rb +16 -0
- data/lib/generators/templates/create_rapns_apps.rb +16 -0
- data/lib/generators/templates/create_rapns_feedback.rb +18 -0
- data/lib/generators/templates/create_rapns_notifications.rb +29 -0
- data/lib/generators/templates/rename_rapns_to_rpush.rb +63 -0
- data/lib/generators/templates/rpush.rb +104 -0
- data/lib/rpush/TODO +3 -0
- data/lib/rpush/adm/app.rb +15 -0
- data/lib/rpush/adm/data_validator.rb +11 -0
- data/lib/rpush/adm/notification.rb +29 -0
- data/lib/rpush/apns/app.rb +29 -0
- data/lib/rpush/apns/binary_notification_validator.rb +12 -0
- data/lib/rpush/apns/device_token_format_validator.rb +12 -0
- data/lib/rpush/apns/feedback.rb +16 -0
- data/lib/rpush/apns/notification.rb +84 -0
- data/lib/rpush/apns_feedback.rb +13 -0
- data/lib/rpush/app.rb +18 -0
- data/lib/rpush/configuration.rb +75 -0
- data/lib/rpush/daemon/adm/delivery.rb +222 -0
- data/lib/rpush/daemon/adm.rb +9 -0
- data/lib/rpush/daemon/apns/certificate_expired_error.rb +20 -0
- data/lib/rpush/daemon/apns/delivery.rb +64 -0
- data/lib/rpush/daemon/apns/disconnection_error.rb +20 -0
- data/lib/rpush/daemon/apns/feedback_receiver.rb +79 -0
- data/lib/rpush/daemon/apns.rb +16 -0
- data/lib/rpush/daemon/app_runner.rb +187 -0
- data/lib/rpush/daemon/batch.rb +115 -0
- data/lib/rpush/daemon/constants.rb +59 -0
- data/lib/rpush/daemon/delivery.rb +28 -0
- data/lib/rpush/daemon/delivery_error.rb +19 -0
- data/lib/rpush/daemon/dispatcher/http.rb +21 -0
- data/lib/rpush/daemon/dispatcher/tcp.rb +30 -0
- data/lib/rpush/daemon/dispatcher_loop.rb +54 -0
- data/lib/rpush/daemon/dispatcher_loop_collection.rb +33 -0
- data/lib/rpush/daemon/feeder.rb +68 -0
- data/lib/rpush/daemon/gcm/delivery.rb +222 -0
- data/lib/rpush/daemon/gcm.rb +9 -0
- data/lib/rpush/daemon/interruptible_sleep.rb +61 -0
- data/lib/rpush/daemon/loggable.rb +31 -0
- data/lib/rpush/daemon/reflectable.rb +13 -0
- data/lib/rpush/daemon/retry_header_parser.rb +23 -0
- data/lib/rpush/daemon/retryable_error.rb +20 -0
- data/lib/rpush/daemon/service_config_methods.rb +33 -0
- data/lib/rpush/daemon/store/active_record/reconnectable.rb +68 -0
- data/lib/rpush/daemon/store/active_record.rb +154 -0
- data/lib/rpush/daemon/tcp_connection.rb +143 -0
- data/lib/rpush/daemon/too_many_requests_error.rb +20 -0
- data/lib/rpush/daemon/wpns/delivery.rb +132 -0
- data/lib/rpush/daemon/wpns.rb +9 -0
- data/lib/rpush/daemon.rb +140 -0
- data/lib/rpush/deprecatable.rb +23 -0
- data/lib/rpush/deprecation.rb +23 -0
- data/lib/rpush/embed.rb +28 -0
- data/lib/rpush/gcm/app.rb +11 -0
- data/lib/rpush/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +11 -0
- data/lib/rpush/gcm/notification.rb +30 -0
- data/lib/rpush/logger.rb +63 -0
- data/lib/rpush/multi_json_helper.rb +16 -0
- data/lib/rpush/notification.rb +69 -0
- data/lib/rpush/notifier.rb +52 -0
- data/lib/rpush/payload_data_size_validator.rb +10 -0
- data/lib/rpush/push.rb +16 -0
- data/lib/rpush/railtie.rb +11 -0
- data/lib/rpush/reflection.rb +58 -0
- data/lib/rpush/registration_ids_count_validator.rb +10 -0
- data/lib/rpush/version.rb +3 -0
- data/lib/rpush/wpns/app.rb +9 -0
- data/lib/rpush/wpns/notification.rb +26 -0
- data/lib/rpush.rb +62 -0
- data/lib/tasks/cane.rake +18 -0
- data/lib/tasks/rpush.rake +16 -0
- data/lib/tasks/test.rake +38 -0
- data/spec/functional/adm_spec.rb +43 -0
- data/spec/functional/apns_spec.rb +58 -0
- data/spec/functional/embed_spec.rb +49 -0
- data/spec/functional/gcm_spec.rb +42 -0
- data/spec/functional/wpns_spec.rb +41 -0
- data/spec/support/cert_with_password.pem +90 -0
- data/spec/support/cert_without_password.pem +59 -0
- data/spec/support/install.sh +32 -0
- data/spec/support/simplecov_helper.rb +20 -0
- data/spec/support/simplecov_quality_formatter.rb +8 -0
- data/spec/tmp/.gitkeep +0 -0
- data/spec/unit/adm/app_spec.rb +58 -0
- data/spec/unit/adm/notification_spec.rb +45 -0
- data/spec/unit/apns/app_spec.rb +29 -0
- data/spec/unit/apns/feedback_spec.rb +9 -0
- data/spec/unit/apns/notification_spec.rb +208 -0
- data/spec/unit/apns_feedback_spec.rb +21 -0
- data/spec/unit/app_spec.rb +30 -0
- data/spec/unit/configuration_spec.rb +45 -0
- data/spec/unit/daemon/adm/delivery_spec.rb +243 -0
- data/spec/unit/daemon/apns/certificate_expired_error_spec.rb +11 -0
- data/spec/unit/daemon/apns/delivery_spec.rb +101 -0
- data/spec/unit/daemon/apns/disconnection_error_spec.rb +18 -0
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +117 -0
- data/spec/unit/daemon/app_runner_spec.rb +292 -0
- data/spec/unit/daemon/batch_spec.rb +232 -0
- data/spec/unit/daemon/delivery_error_spec.rb +13 -0
- data/spec/unit/daemon/delivery_spec.rb +38 -0
- data/spec/unit/daemon/dispatcher/http_spec.rb +33 -0
- data/spec/unit/daemon/dispatcher/tcp_spec.rb +38 -0
- data/spec/unit/daemon/dispatcher_loop_collection_spec.rb +37 -0
- data/spec/unit/daemon/dispatcher_loop_spec.rb +71 -0
- data/spec/unit/daemon/feeder_spec.rb +98 -0
- data/spec/unit/daemon/gcm/delivery_spec.rb +310 -0
- data/spec/unit/daemon/interruptible_sleep_spec.rb +68 -0
- data/spec/unit/daemon/reflectable_spec.rb +27 -0
- data/spec/unit/daemon/retryable_error_spec.rb +14 -0
- data/spec/unit/daemon/service_config_methods_spec.rb +33 -0
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +114 -0
- data/spec/unit/daemon/store/active_record_spec.rb +357 -0
- data/spec/unit/daemon/tcp_connection_spec.rb +287 -0
- data/spec/unit/daemon/too_many_requests_error_spec.rb +14 -0
- data/spec/unit/daemon/wpns/delivery_spec.rb +159 -0
- data/spec/unit/daemon_spec.rb +159 -0
- data/spec/unit/deprecatable_spec.rb +32 -0
- data/spec/unit/deprecation_spec.rb +15 -0
- data/spec/unit/embed_spec.rb +50 -0
- data/spec/unit/gcm/app_spec.rb +4 -0
- data/spec/unit/gcm/notification_spec.rb +36 -0
- data/spec/unit/logger_spec.rb +127 -0
- data/spec/unit/notification_shared.rb +105 -0
- data/spec/unit/notification_spec.rb +15 -0
- data/spec/unit/notifier_spec.rb +49 -0
- data/spec/unit/push_spec.rb +43 -0
- data/spec/unit/reflection_spec.rb +30 -0
- data/spec/unit/rpush_spec.rb +9 -0
- data/spec/unit/wpns/app_spec.rb +4 -0
- data/spec/unit/wpns/notification_spec.rb +30 -0
- data/spec/unit_spec_helper.rb +101 -0
- metadata +304 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd3933018cb97f85a06df0df090aade180c8763c
|
4
|
+
data.tar.gz: 689b13f47bb1ec8f2a371ad175e63e5c929ba6b6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ca7768f9249d0f04553bd505f5f4bf929538a730eb24ce59bc37f041fddde8a55588e8758ce313902bfcd32716a49d51acb85ee226bb7e4343d0127b2922249
|
7
|
+
data.tar.gz: d5cbc3465122d36dd5222928fea8ab901a77d58bffdf6d25c84092ea43c8cbeac4b9f004241caabbc5bb8f27fc112dc22dba2d0be2f7e93fba7937119a1739d1
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
## 1.0.0 (Feb 9, 2014)
|
2
|
+
* Renamed to Rpush (from Rapns). Version number reset to 1.0.0.
|
3
|
+
* Reduce default batch size to 100.
|
4
|
+
* Fix sqlite3 support (#160).
|
5
|
+
* Drop support for Ruby 1.8.
|
6
|
+
* Improve APNs certificate validation errors (#192) @mattconnolly).
|
7
|
+
* Support for Windows Phone notifications (#191) (@matiaslina).
|
8
|
+
* Support for Amazon device messaging (#173) (@darrylyip).
|
9
|
+
* Add two new GCM reflections: gcm_delivered_to_recipient, gcm_failed_to_recipient (#184) (@jakeonfire).
|
10
|
+
* Fix migration issues (#181) (@jcoleman).
|
11
|
+
* Add GCM gcm_invalid_registration_id reflection (#171) (@marcrohloff).
|
12
|
+
* Feature: wakeup feeder via UDP socket (#164) (@mattconnolly).
|
13
|
+
* Fix reflections when using batches (#161).
|
14
|
+
* Only perform APNs certificate validation for APNs apps (#133).
|
15
|
+
* The deprecated on_apns_feedback has now been removed.
|
16
|
+
* The deprecated airbrake_notify config option has been removed.
|
17
|
+
* Removed the deprecated ability to set attributes_for_device using mass-assignment.
|
18
|
+
* Fixed issue where database connections may not be released from the connection pool.
|
19
|
+
|
20
|
+
## 3.4.1 (Aug 30, 2013)
|
21
|
+
* Silence unintended airbrake_notify deprecation warning (#158).
|
22
|
+
* Add :dependent => :destroy to app notifications (#156).
|
23
|
+
|
24
|
+
## 3.4.0 (Aug 28, 2013)
|
25
|
+
* Rails 4 support.
|
26
|
+
* Add apns_certificate_will_expire reflection.
|
27
|
+
* Perform storage update in batches where possible, to increase throughput.
|
28
|
+
* airbrake_notify is now deprecated, use the Reflection API instead.
|
29
|
+
* Fix calling the notification_delivered reflection twice (#149).
|
30
|
+
|
31
|
+
## 3.3.2 (June 30, 2013)
|
32
|
+
* Fix Rails 3.0.x compatibility (#138) (@yoppi).
|
33
|
+
* Ensure Rails does not set a default value for text columns (#137).
|
34
|
+
* Fix error in down action for add_gcm migration (#135) (@alexperto).
|
35
|
+
|
36
|
+
## 3.3.1 (June 2, 2013)
|
37
|
+
* Fix compatibility with postgres_ext (#104).
|
38
|
+
* Add ability to switch the logger (@maxsz).
|
39
|
+
* Do not validate presence of alert, badge or sound - not actually required by the APNs (#129) (@wilg).
|
40
|
+
* Catch IOError from an APNs connection. (@maxsz).
|
41
|
+
* Allow nested hashes in APNs notification attributes (@perezda).
|
42
|
+
|
43
|
+
## 3.3.0 (April 21, 2013)
|
44
|
+
* GCM: collapse_key is no longer required to set expiry (time_to_live).
|
45
|
+
* Add reflection for GCM canonical IDs.
|
46
|
+
* Add Rpush::Daemon.store to decouple storage backend.
|
47
|
+
|
48
|
+
## 3.2.0 (Apr 1, 2013)
|
49
|
+
* Rpush.apns_feedback for one time feedback retrieval. Rpush.push no longer checks for feedback (#117, #105).
|
50
|
+
* Lazily connect to the APNs only when a notification is to be delivered (#111).
|
51
|
+
* Ensure all notifications are sent when using Rpush.push (#107).
|
52
|
+
* Fix issue with running Rpush.push more than once in the same process (#106).
|
53
|
+
|
54
|
+
## 3.1.0 (Jan 26, 2013)
|
55
|
+
* Rpush.reflect API for fine-grained introspection.
|
56
|
+
* Rpush.embed API for embedding Rpush into an existing process.
|
57
|
+
* Rpush.push API for using Rpush in scheduled jobs.
|
58
|
+
* Fix issue with integration with ActiveScaffold (#98) (@jeffarena).
|
59
|
+
* Fix content-available setter for APNs (#95) (@dup2).
|
60
|
+
* GCM validation fixes (#96) (@DianthuDia).
|
61
|
+
|
62
|
+
## 3.0.1 (Dec 16, 2012)
|
63
|
+
* Fix compatibility with Rails 3.0.x. Fixes #89.
|
64
|
+
|
65
|
+
## 3.0.0 (Dec 15, 2012)
|
66
|
+
* Add support for Google Cloud Messaging.
|
67
|
+
* Fix Heroku logging issue.
|
68
|
+
|
69
|
+
## 2.0.5 (Nov 4, 2012) ##
|
70
|
+
* Support content-available (#68).
|
71
|
+
* Append to log files.
|
72
|
+
* Fire a callback when Feedback is received.
|
73
|
+
|
74
|
+
## 2.0.5.rc1 (Oct 5, 2012) ##
|
75
|
+
* Release db connections back into the pool after use (#72).
|
76
|
+
* Continue to start daemon if a connection cannot be made during startup (#62) (@mattconnolly).
|
77
|
+
|
78
|
+
## 2.0.4 (Aug 6, 2012) ##
|
79
|
+
* Don't exit when there aren't any Rpush::App instances, just warn (#55).
|
80
|
+
|
81
|
+
## 2.0.3 (July 26, 2012) ##
|
82
|
+
* JRuby support.
|
83
|
+
* Explicitly list all attributes instead of calling column_names (#53).
|
84
|
+
|
85
|
+
## 2.0.2 (July 25, 2012) ##
|
86
|
+
* Support MultiJson < 1.3.0.
|
87
|
+
* Make all model attributes accessible.
|
88
|
+
|
89
|
+
## 2.0.1 (July 7, 2012) ##
|
90
|
+
* Fix delivery when using Ruby 1.8.
|
91
|
+
* MultiJson support.
|
92
|
+
|
93
|
+
## 2.0.0 (June 19, 2012) ##
|
94
|
+
|
95
|
+
* Support for multiple apps.
|
96
|
+
* Hot Updates - add/remove apps without restart.
|
97
|
+
* MDM support.
|
98
|
+
* Removed rpush.yml in favour of command line options.
|
99
|
+
* Started the changelog!
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2012 Ian Leitch
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/rpush/rpush.png?branch=master)](http://travis-ci.org/rpush/rpush)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/rpush/rpush.png)](https://codeclimate.com/github/rpush/rpush)
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/rpush/rpush/badge.png?branch=master)](https://coveralls.io/r/rpush/rpush?branch=master)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/rpush.png)](http://badge.fury.io/rb/rpush)
|
5
|
+
|
6
|
+
<img src="https://raw.github.com/rpush/rpush/master/rpush.png" align="right" width="200px" />
|
7
|
+
|
8
|
+
### Rpush. The push notification service for Ruby.
|
9
|
+
|
10
|
+
* Supports:
|
11
|
+
* **Apple Push Notification Service**
|
12
|
+
* **Google Cloud Messaging)**
|
13
|
+
* **Amazon Devide Messaging**
|
14
|
+
* **Windows Push Notification Service**.
|
15
|
+
* Seamless Rails (3, 4) integration.
|
16
|
+
* Scalable - choose the number of persistent connections for each app.
|
17
|
+
* Designed for uptime - signal -HUP to add, update apps.
|
18
|
+
* Run as a daemon or inside an [existing processs](https://github.com/rpush/rpush/wiki/Embedding-API).
|
19
|
+
* Use in a scheduler for low-workload deployments ([Push API](https://github.com/rpush/rpush/wiki/Push-API)).
|
20
|
+
* Hooks for fine-grained instrumentation and error handling ([Reflection API](https://github.com/rpush/rpush/wiki/Reflection-API)).
|
21
|
+
* Works with MRI, JRuby, Rubinius 1.9, 2.0, 2.1.
|
22
|
+
|
23
|
+
|
24
|
+
### Getting Started
|
25
|
+
|
26
|
+
Add it to your Gemfile:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gem 'rpush'
|
30
|
+
```
|
31
|
+
|
32
|
+
Generate the migrations, rpush.yml and migrate:
|
33
|
+
|
34
|
+
```
|
35
|
+
rails g rpush
|
36
|
+
rake db:migrate
|
37
|
+
```
|
38
|
+
|
39
|
+
### Create an App & Notification
|
40
|
+
|
41
|
+
#### Apple Push Notification Service
|
42
|
+
|
43
|
+
If this is your first time using the APNs, you will need to generate SSL certificates. See [Generating Certificates](https://github.com/rpush/rpush/wiki/Generating-Certificates) for instructions.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
app = Rpush::Apns::App.new
|
47
|
+
app.name = "ios_app"
|
48
|
+
app.certificate = File.read("/path/to/sandbox.pem")
|
49
|
+
app.environment = "sandbox" # APNs environment.
|
50
|
+
app.password = "certificate password"
|
51
|
+
app.connections = 1
|
52
|
+
app.save!
|
53
|
+
```
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
n = Rpush::Apns::Notification.new
|
57
|
+
n.app = Rpush::Apns::App.find_by_name("ios_app")
|
58
|
+
n.device_token = "..."
|
59
|
+
n.alert = "hi mom!"
|
60
|
+
n.attributes_for_device = {:foo => :bar}
|
61
|
+
n.save!
|
62
|
+
```
|
63
|
+
|
64
|
+
You should also implement the [ssl_certificate_will_expire](https://github.com/rpush/rpush/wiki/Reflection-API) reflection to monitor when your certificate is due to expire.
|
65
|
+
|
66
|
+
#### Google Cloud Messaging
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
app = Rpush::Gcm::App.new
|
70
|
+
app.name = "android_app"
|
71
|
+
app.auth_key = "..."
|
72
|
+
app.connections = 1
|
73
|
+
app.save!
|
74
|
+
```
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
n = Rpush::Gcm::Notification.new
|
78
|
+
n.app = Rpush::Gcm::App.find_by_name("android_app")
|
79
|
+
n.registration_ids = ["..."]
|
80
|
+
n.data = {:message => "hi mom!"}
|
81
|
+
n.save!
|
82
|
+
```
|
83
|
+
|
84
|
+
GCM also requires you to respond to [Canonical IDs](https://github.com/rpush/rpush/wiki/Canonical-IDs).
|
85
|
+
|
86
|
+
#### Amazon Device Messaging
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
app = Rpush::Adm::App.new
|
90
|
+
app.name = "kindle_app"
|
91
|
+
app.client_id = "..."
|
92
|
+
app.client_secret = "..."
|
93
|
+
app.connections = 1
|
94
|
+
app.save!
|
95
|
+
```
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
n = Rpush::Adm::Notification.new
|
99
|
+
n.app = Rpush::Adm::App.find_by_name("kindle_app")
|
100
|
+
n.registration_ids = ["..."]
|
101
|
+
n.data = {:message => "hi mom!"}
|
102
|
+
n.collapse_key = "Optional consolidationKey"
|
103
|
+
n.save!
|
104
|
+
```
|
105
|
+
|
106
|
+
For more documentation on [ADM](https://developer.amazon.com/sdk/adm.html).
|
107
|
+
|
108
|
+
#### Windows Phone Notification Service
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
app = Rpush::Wpns::App.new
|
112
|
+
app.name = "windows_phone_app"
|
113
|
+
app.connections = 1
|
114
|
+
app.save!
|
115
|
+
```
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
n = Rpush::Wpns::Notification.new
|
119
|
+
n.app = Rpush::Wpns::App.find_by_name("windows_phone_app")
|
120
|
+
n.uri = "http://..."
|
121
|
+
n.alert = "..."
|
122
|
+
n.save!
|
123
|
+
```
|
124
|
+
|
125
|
+
### Starting Rpush
|
126
|
+
|
127
|
+
As a daemon:
|
128
|
+
|
129
|
+
cd /path/to/rails/app
|
130
|
+
rpush <Rails environment> [options]
|
131
|
+
|
132
|
+
Inside an existing process (see [Embedding API](https://github.com/rpush/rpush/wiki/Embedding-API)):
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
Rpush.embed
|
136
|
+
```
|
137
|
+
|
138
|
+
*Please note that only ever a single instance of Rpush should be running.*
|
139
|
+
|
140
|
+
In a scheduler (see [Push API](https://github.com/rpush/rpush/wiki/Push-API)):
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
Rpush.push
|
144
|
+
Rpush.apns_feedback
|
145
|
+
```
|
146
|
+
|
147
|
+
See [Configuration](https://github.com/rpush/rpush/wiki/Configuration) for a list of options, or run `rpush --help`.
|
148
|
+
|
149
|
+
### Updating Rpush
|
150
|
+
|
151
|
+
After updating you should run `rails g rpush` to check for any new migrations.
|
152
|
+
|
153
|
+
### Wiki
|
154
|
+
|
155
|
+
### General
|
156
|
+
* [Configuration](https://github.com/rpush/rpush/wiki/Configuration)
|
157
|
+
* [Moving from Rapns](https://github.com/rpush/rpush/wiki/Moving-from-Rapns-to-Rpush)
|
158
|
+
* [Deploying to Heroku](https://github.com/rpush/rpush/wiki/Heroku)
|
159
|
+
* [Hot App Updates](https://github.com/rpush/rpush/wiki/Hot-App-Updates)
|
160
|
+
* [Signals](https://github.com/rpush/rpush/wiki/Signals)
|
161
|
+
* [Reflection API](https://github.com/rpush/rpush/wiki/Reflection-API)
|
162
|
+
* [Push API](https://github.com/rpush/rpush/wiki/Push-API)
|
163
|
+
* [Embedding API](https://github.com/rpush/rpush/wiki/Embedding-API)
|
164
|
+
* [Implementing your own storage backend](https://github.com/rpush/rpush/wiki/Implementing-your-own-storage-backend)
|
165
|
+
* [Upgrading from 2.x to 3.0](https://github.com/rpush/rpush/wiki/Upgrading-from-version-2.x-to-3.0)
|
166
|
+
|
167
|
+
### Apple Push Notification Service
|
168
|
+
* [Generating Certificates](https://github.com/rpush/rpush/wiki/Generating-Certificates)
|
169
|
+
* [Advanced APNs Features](https://github.com/rpush/rpush/wiki/Advanced-APNs-Features)
|
170
|
+
* [APNs Delivery Failure Handling](https://github.com/rpush/rpush/wiki/APNs-Delivery-Failure-Handling)
|
171
|
+
* [Why open multiple connections to the APNs?](https://github.com/rpush/rpush/wiki/Why-open-multiple-connections-to-the-APNs%3F)
|
172
|
+
* [Silent failures might be dropped connections](https://github.com/rpush/rpush/wiki/Dropped-connections)
|
173
|
+
|
174
|
+
### Google Cloud Messaging
|
175
|
+
* [Notification Options](https://github.com/rpush/rpush/wiki//GCM-Notification-Options)
|
176
|
+
* [Canonical IDs](https://github.com/rpush/rpush/wiki/Canonical-IDs)
|
177
|
+
* [Delivery Failures & Retries](https://github.com/rpush/rpush/wiki/Delivery-Failures-&-Retries)
|
178
|
+
|
179
|
+
### Contributing
|
180
|
+
|
181
|
+
Fork as usual and go crazy!
|
182
|
+
|
183
|
+
When running specs, please note that the ActiveRecord adapter can be changed by setting the `ADAPTER` environment variable. For example: `ADAPTER=postgresql rake`.
|
184
|
+
|
185
|
+
Available adapters for testing are `mysql`, `mysql2` and `postgresql`.
|
186
|
+
|
187
|
+
Note that the database username is changed at runtime to be the currently logged in user's name. So if you're testing
|
188
|
+
with mysql and you're using a user named 'bob', you will need to grant a mysql user 'bob' access to the 'rpush_test'
|
189
|
+
mysql database.
|
data/bin/rpush
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'rpush'
|
5
|
+
|
6
|
+
environment = ARGV[0]
|
7
|
+
|
8
|
+
config = Rpush::ConfigurationWithoutDefaults.new
|
9
|
+
|
10
|
+
options = ARGV.options do |opts|
|
11
|
+
opts.banner = 'Usage: rpush <Rails environment> [options]'
|
12
|
+
opts.on('-f', '--foreground', 'Run in the foreground.') { config.foreground = true }
|
13
|
+
opts.on('-P N', '--db-poll N', Integer, "Frequency in seconds to check for new notifications.") { |n| config.push_poll = n }
|
14
|
+
opts.on('-F N', '--feedback-poll N', Integer, "Frequency in seconds to check for feedback.") { |n| config.feedback_poll = n }
|
15
|
+
opts.on('-e', '--no-error-checks', 'Disable APNs error checking after notification delivery.') { config.check_for_errors = false }
|
16
|
+
opts.on('-p PATH', '--pid-file PATH', String, 'Path to write PID file. Relative to Rails root unless absolute.') { |path| config.pid_file = path }
|
17
|
+
opts.on('-b N', '--batch-size N', Integer, 'Storage backend notification batch size.') { |n| config.batch_size = n }
|
18
|
+
opts.on('-B', '--[no-]batch-storage-updates', 'Perform storage updates in batches.') { |v| config.batch_storage_updates = v }
|
19
|
+
opts.on('-v', '--version', 'Print the version.') { puts "rpush #{Rpush::VERSION}"; exit }
|
20
|
+
opts.on('-h', '--help', 'You\'re looking at it.') { puts opts; exit }
|
21
|
+
end
|
22
|
+
|
23
|
+
if environment.nil? || environment =~ /^-/
|
24
|
+
puts options.to_s
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
options.parse!
|
29
|
+
|
30
|
+
ENV['RAILS_ENV'] = environment
|
31
|
+
load 'config/environment.rb'
|
32
|
+
load 'config/initializers/rpush.rb' if File.exist?('config/initializers/rpush.rb')
|
33
|
+
|
34
|
+
Rpush.config.update(config)
|
35
|
+
Rpush.require_for_daemon
|
36
|
+
Rpush::Daemon.start
|
data/config/database.yml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# postgresql is the default if no ADAPTER environment variable is set when running specs.
|
2
|
+
|
3
|
+
postgresql:
|
4
|
+
adapter: postgresql
|
5
|
+
database: rpush_test
|
6
|
+
host: localhost
|
7
|
+
username: postgres
|
8
|
+
password: ""
|
9
|
+
|
10
|
+
jdbcpostgresql:
|
11
|
+
adapter: jdbcpostgresql
|
12
|
+
database: rpush_test
|
13
|
+
host: localhost
|
14
|
+
username: postgres
|
15
|
+
password: ""
|
16
|
+
|
17
|
+
mysql2:
|
18
|
+
adapter: mysql2
|
19
|
+
database: rpush_test
|
20
|
+
host: localhost
|
21
|
+
username: rpush_test
|
22
|
+
password: ""
|
23
|
+
encoding: utf8
|
24
|
+
|
25
|
+
jdbcmysql:
|
26
|
+
adapter: jdbcmysql
|
27
|
+
database: rpush_test
|
28
|
+
host: localhost
|
29
|
+
username: rpush_test
|
30
|
+
password: ""
|
31
|
+
encoding: utf8
|
32
|
+
|
33
|
+
jdbch2:
|
34
|
+
adapter: h2
|
35
|
+
url: jdbc:h2:file:/tmp/rpush_test;AUTO_SERVER=TRUE
|
36
|
+
username: rpush_test
|
37
|
+
password: ""
|
38
|
+
pool: 128
|
39
|
+
timeout: 5000
|
40
|
+
encoding: utf8
|
41
|
+
|
42
|
+
sqlite3:
|
43
|
+
adapter: sqlite3
|
44
|
+
database: spec/tmp/rpush_test.sqlite3
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class RpushGenerator < Rails::Generators::Base
|
2
|
+
include Rails::Generators::Migration
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def self.next_migration_number(path)
|
6
|
+
@time ||= Time.now.utc
|
7
|
+
@calls ||= -1
|
8
|
+
@calls += 1
|
9
|
+
(@time + @calls.seconds).strftime("%Y%m%d%H%M%S")
|
10
|
+
end
|
11
|
+
|
12
|
+
def copy_migration
|
13
|
+
if has_migration?('create_rapns_notifications')
|
14
|
+
add_rpush_migration('create_rapns_feedback')
|
15
|
+
add_rpush_migration('add_alert_is_json_to_rapns_notifications')
|
16
|
+
add_rpush_migration('add_app_to_rapns')
|
17
|
+
add_rpush_migration('create_rapns_apps')
|
18
|
+
add_rpush_migration('add_gcm')
|
19
|
+
add_rpush_migration('add_wpns')
|
20
|
+
add_rpush_migration('add_adm')
|
21
|
+
add_rpush_migration('rename_rapns_to_rpush')
|
22
|
+
add_rpush_migration('add_fail_after_to_rpush_notifications')
|
23
|
+
else
|
24
|
+
add_rpush_migration('add_rpush')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def copy_config
|
29
|
+
copy_file 'rpush.rb', 'config/initializers/rpush.rb'
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def add_rpush_migration(template)
|
35
|
+
if !has_migration?(template)
|
36
|
+
migration_template "#{template}.rb", "db/migrate/#{template}.rb"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def has_migration?(template)
|
41
|
+
migration_dir = File.expand_path('db/migrate')
|
42
|
+
self.class.migration_exists?(migration_dir, template)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class AddAdm < ActiveRecord::Migration
|
2
|
+
module Rapns
|
3
|
+
class Notification < ActiveRecord::Base
|
4
|
+
self.table_name = 'rapns_notifications'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.up
|
9
|
+
add_column :rapns_apps, :client_id, :string, :null => true
|
10
|
+
add_column :rapns_apps, :client_secret, :string, :null => true
|
11
|
+
add_column :rapns_apps, :access_token, :string, :null => true
|
12
|
+
add_column :rapns_apps, :access_token_expiration, :datetime, :null => true
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
AddAdm::Rapns::Notification.where(:type => 'Rapns::Adm::Notification').delete_all
|
17
|
+
|
18
|
+
remove_column :rapns_apps, :client_id
|
19
|
+
remove_column :rapns_apps, :client_secret
|
20
|
+
remove_column :rapns_apps, :access_token
|
21
|
+
remove_column :rapns_apps, :access_token_expiration
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddAppToRapns < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :rapns_notifications, :app, :string, :null => true
|
4
|
+
add_column :rapns_feedback, :app, :string, :null => true
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.down
|
8
|
+
remove_column :rapns_notifications, :app
|
9
|
+
remove_column :rapns_feedback, :app
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
class AddGcm < ActiveRecord::Migration
|
2
|
+
module Rapns
|
3
|
+
class App < ActiveRecord::Base
|
4
|
+
self.table_name = 'rapns_apps'
|
5
|
+
end
|
6
|
+
|
7
|
+
class Notification < ActiveRecord::Base
|
8
|
+
belongs_to :app
|
9
|
+
self.table_name = 'rapns_notifications'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.up
|
14
|
+
add_column :rapns_notifications, :type, :string, :null => true
|
15
|
+
add_column :rapns_apps, :type, :string, :null => true
|
16
|
+
|
17
|
+
AddGcm::Rapns::Notification.update_all :type => 'Rapns::Apns::Notification'
|
18
|
+
AddGcm::Rapns::App.update_all :type => 'Rapns::Apns::App'
|
19
|
+
|
20
|
+
change_column :rapns_notifications, :type, :string, :null => false
|
21
|
+
change_column :rapns_apps, :type, :string, :null => false
|
22
|
+
change_column :rapns_notifications, :device_token, :string, { :null => true, :limit => 64 }
|
23
|
+
change_column :rapns_notifications, :expiry, :integer, { :null => true, :default => 1.day.to_i }
|
24
|
+
change_column :rapns_apps, :environment, :string, :null => true
|
25
|
+
change_column :rapns_apps, :certificate, :text, :null => true, :default => nil
|
26
|
+
|
27
|
+
change_column :rapns_notifications, :error_description, :text, :null => true, :default => nil
|
28
|
+
change_column :rapns_notifications, :sound, :string, :default => 'default'
|
29
|
+
|
30
|
+
rename_column :rapns_notifications, :attributes_for_device, :data
|
31
|
+
rename_column :rapns_apps, :key, :name
|
32
|
+
|
33
|
+
add_column :rapns_apps, :auth_key, :string, :null => true
|
34
|
+
|
35
|
+
add_column :rapns_notifications, :collapse_key, :string, :null => true
|
36
|
+
add_column :rapns_notifications, :delay_while_idle, :boolean, :null => false, :default => false
|
37
|
+
|
38
|
+
reg_ids_type = ActiveRecord::Base.connection.adapter_name.include?('Mysql') ? :mediumtext : :text
|
39
|
+
add_column :rapns_notifications, :registration_ids, reg_ids_type, :null => true
|
40
|
+
add_column :rapns_notifications, :app_id, :integer, :null => true
|
41
|
+
add_column :rapns_notifications, :retries, :integer, :null => true, :default => 0
|
42
|
+
|
43
|
+
AddGcm::Rapns::Notification.reset_column_information
|
44
|
+
AddGcm::Rapns::App.reset_column_information
|
45
|
+
|
46
|
+
AddGcm::Rapns::App.all.each do |app|
|
47
|
+
AddGcm::Rapns::Notification.update_all(['app_id = ?', app.id], ['app = ?', app.name])
|
48
|
+
end
|
49
|
+
|
50
|
+
change_column :rapns_notifications, :app_id, :integer, :null => false
|
51
|
+
remove_column :rapns_notifications, :app
|
52
|
+
|
53
|
+
if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi", true)
|
54
|
+
remove_index :rapns_notifications, :name => "index_rapns_notifications_multi"
|
55
|
+
elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after", false)
|
56
|
+
remove_index :rapns_notifications, :name => "index_rapns_notifications_on_delivered_failed_deliver_after"
|
57
|
+
end
|
58
|
+
add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], :name => "index_rapns_notifications_multi"
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.down
|
62
|
+
AddGcm::Rapns::Notification.where(:type => 'Rapns::Gcm::Notification').delete_all
|
63
|
+
|
64
|
+
remove_column :rapns_notifications, :type
|
65
|
+
remove_column :rapns_apps, :type
|
66
|
+
|
67
|
+
change_column :rapns_notifications, :device_token, :string, { :null => false, :limit => 64 }
|
68
|
+
change_column :rapns_notifications, :expiry, :integer, { :null => false, :default => 1.day.to_i }
|
69
|
+
change_column :rapns_apps, :environment, :string, :null => false
|
70
|
+
change_column :rapns_apps, :certificate, :text, :null => false
|
71
|
+
|
72
|
+
change_column :rapns_notifications, :error_description, :string, :null => true, :default => nil
|
73
|
+
change_column :rapns_notifications, :sound, :string, :default => '1.aiff'
|
74
|
+
|
75
|
+
rename_column :rapns_notifications, :data, :attributes_for_device
|
76
|
+
rename_column :rapns_apps, :name, :key
|
77
|
+
|
78
|
+
remove_column :rapns_apps, :auth_key
|
79
|
+
|
80
|
+
remove_column :rapns_notifications, :collapse_key
|
81
|
+
remove_column :rapns_notifications, :delay_while_idle
|
82
|
+
remove_column :rapns_notifications, :registration_ids
|
83
|
+
remove_column :rapns_notifications, :retries
|
84
|
+
|
85
|
+
add_column :rapns_notifications, :app, :string, :null => true
|
86
|
+
|
87
|
+
AddGcm::Rapns::Notification.reset_column_information
|
88
|
+
AddGcm::Rapns::App.reset_column_information
|
89
|
+
|
90
|
+
AddGcm::Rapns::App.all.each do |app|
|
91
|
+
AddGcm::Rapns::Notification.update_all(['app = ?', app.key], ['app_id = ?', app.id])
|
92
|
+
end
|
93
|
+
|
94
|
+
if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi, true)
|
95
|
+
remove_index :rapns_notifications, :name => :index_rapns_notifications_multi
|
96
|
+
end
|
97
|
+
|
98
|
+
remove_column :rapns_notifications, :app_id
|
99
|
+
|
100
|
+
add_index :rapns_notifications, [:delivered, :failed, :deliver_after], :name => :index_rapns_notifications_multi
|
101
|
+
end
|
102
|
+
end
|