rpush 8.0.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -6
  3. data/README.md +8 -65
  4. data/lib/generators/templates/rpush.rb +9 -16
  5. data/lib/rpush/client/active_model.rb +0 -4
  6. data/lib/rpush/client/active_record.rb +0 -3
  7. data/lib/rpush/client/redis.rb +0 -3
  8. data/lib/rpush/configuration.rb +2 -19
  9. data/lib/rpush/daemon/service_config_methods.rb +0 -2
  10. data/lib/rpush/daemon/store/active_record.rb +2 -14
  11. data/lib/rpush/daemon/store/interface.rb +2 -2
  12. data/lib/rpush/daemon/store/redis.rb +2 -11
  13. data/lib/rpush/daemon.rb +0 -10
  14. data/lib/rpush/reflection_collection.rb +1 -2
  15. data/lib/rpush/version.rb +1 -1
  16. data/lib/rpush.rb +0 -1
  17. data/spec/functional/cli_spec.rb +41 -15
  18. data/spec/functional/embed_spec.rb +57 -26
  19. data/spec/functional/retry_spec.rb +21 -4
  20. data/spec/functional/synchronization_spec.rb +1 -1
  21. data/spec/functional_spec_helper.rb +0 -6
  22. data/spec/spec_helper.rb +2 -0
  23. data/spec/unit/client/active_record/shared/app.rb +1 -1
  24. data/spec/unit/daemon/shared/store.rb +0 -42
  25. metadata +49 -55
  26. data/lib/rpush/apns_feedback.rb +0 -18
  27. data/lib/rpush/client/active_model/gcm/app.rb +0 -19
  28. data/lib/rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +0 -14
  29. data/lib/rpush/client/active_model/gcm/notification.rb +0 -62
  30. data/lib/rpush/client/active_record/gcm/app.rb +0 -11
  31. data/lib/rpush/client/active_record/gcm/notification.rb +0 -11
  32. data/lib/rpush/client/redis/gcm/app.rb +0 -11
  33. data/lib/rpush/client/redis/gcm/notification.rb +0 -11
  34. data/lib/rpush/daemon/apns/delivery.rb +0 -43
  35. data/lib/rpush/daemon/apns/feedback_receiver.rb +0 -91
  36. data/lib/rpush/daemon/apns.rb +0 -17
  37. data/lib/rpush/daemon/dispatcher/apns_tcp.rb +0 -152
  38. data/lib/rpush/daemon/dispatcher/tcp.rb +0 -22
  39. data/lib/rpush/daemon/gcm/delivery.rb +0 -241
  40. data/lib/rpush/daemon/gcm.rb +0 -9
  41. data/lib/rpush/daemon/tcp_connection.rb +0 -190
  42. data/spec/functional/apns_spec.rb +0 -162
  43. data/spec/functional/gcm_priority_spec.rb +0 -40
  44. data/spec/functional/gcm_spec.rb +0 -46
  45. data/spec/functional/new_app_spec.rb +0 -44
  46. data/spec/unit/apns_feedback_spec.rb +0 -39
  47. data/spec/unit/client/active_record/gcm/app_spec.rb +0 -6
  48. data/spec/unit/client/active_record/gcm/notification_spec.rb +0 -14
  49. data/spec/unit/client/redis/gcm/app_spec.rb +0 -5
  50. data/spec/unit/client/redis/gcm/notification_spec.rb +0 -5
  51. data/spec/unit/client/shared/gcm/app.rb +0 -4
  52. data/spec/unit/client/shared/gcm/notification.rb +0 -77
  53. data/spec/unit/daemon/apns/delivery_spec.rb +0 -108
  54. data/spec/unit/daemon/apns/feedback_receiver_spec.rb +0 -137
  55. data/spec/unit/daemon/dispatcher/tcp_spec.rb +0 -32
  56. data/spec/unit/daemon/gcm/delivery_spec.rb +0 -387
  57. data/spec/unit/daemon/tcp_connection_spec.rb +0 -293
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 563933a59960a39b083c6fa55d8300d1b92c29e332cb7ecded294ecc772965ef
4
- data.tar.gz: dd9f6cba0c315d7398266a00a1c59cd121ad0167f1217e7781acb402d5ee12e9
3
+ metadata.gz: e4ab9013682357312b9f5050d6c466c62866f78c68cc0fcb72ad89ccdc4409e0
4
+ data.tar.gz: ab086d28a744140499a6434c5fcec99b6c77c4cd929163a02ac4d9d77f94bb99
5
5
  SHA512:
6
- metadata.gz: ab9641db8c6e0b0f77b1655d00082d29abb8ef0e83eadc640460abbad6624c96b1641501b597de20cc8c5c9dc8d39ecc34673ad174e6e42f0e036168822c36f9
7
- data.tar.gz: 6218b33d044790b48cc8f14b4d3d43cbef90a1189daf52b248db2052c45d36120b946412e449212726d63ccb8392640f2cebe4bc0d02c904aa688ae27cec3354
6
+ metadata.gz: 862a057ab8cce2f73eff784838302ac0128214e0f744ed108b91afb33dce0867f7e7f06e131a29b46f6f49be7cca4e809f317ed37c50d1512eaa480a8ad7532d
7
+ data.tar.gz: 2f2d5cd377c79a1ec1ada2677f5c409d58d27d40a90b899b7fd43b98f122148623a0a78ca17c862b18b38245fe2df9a2f1cc7c68f25dc8cbe3dfa48a1f779c1f
data/CHANGELOG.md CHANGED
@@ -4,17 +4,23 @@
4
4
 
5
5
  **Merged pull requests:**
6
6
 
7
- * Support for FCMv1 [\#620](https://github.com/rpush/rpush/pull/620) ([mirkode](https://github.com/mirkode)), [\#660](https://github.com/rpush/rpush/pull/660) ([AnilRh](https://github.com/AnilRh)) and [\#673](https://github.com/rpush/rpush/pull/673) ([SixiS](https://github.com/SixiS), [Henridv](https://github.com/Henridv) & [benlangfeld](https://github.com/benlangfeld))
8
- * No longer silence content-available notifications for APNs. Reverts the following change from the v6.0.0 release. See https://github.com/rpush/rpush/issues/647.
9
- * Fix silent APNS notifications for Apns2 and Apnsp8 [\#596](https://github.com/rpush/rpush/pull/596) ([shved270189](https://github.com/shved270189))
7
+ [Full Changelog](https://github.com/rpush/rpush/compare/v9.0.0...HEAD)
8
+
9
+ ## [v9.0.0](https://github.com/rpush/rpush/tree/v9.0.0) (2024-09-09)
10
+
11
+ **Merged pull requests:**
12
+
13
+ * Support for Ruby 3.2 & 3.3 [\#679](https://github.com/rpush/rpush/pull/679) ([benlangfeld](https://github.com/benlangfeld))
10
14
 
11
15
  **Breaking:**
12
16
 
13
- * Dropped support for Ruby 2.4, 2.5, 2.6 and Rails 5.2.
17
+ * Removed legacy APNSv1 implementation (Apple binary protocol) since this was shut down in 2021. [\#680](https://github.com/rpush/rpush/pull/680) ([benlangfeld](https://github.com/benlangfeld))
18
+ * Removed legacy GCM implementation since this was shut down by Google in August 2024 and replaced by FCM (supported in RPush 8.0.0) [\#688](https://github.com/rpush/rpush/pull/688) ([benlangfeld](https://github.com/benlangfeld))
19
+ * Drop support for Ruby 2.x [\#672](https://github.com/rpush/rpush/pull/672) ([benlangfeld](https://github.com/benlangfeld))
14
20
 
15
- [Full Changelog](https://github.com/rpush/rpush/compare/v8.0.0...HEAD)
21
+ [Full Changelog](https://github.com/rpush/rpush/compare/v8.0.0...v9.0.0)
16
22
 
17
- ## [v7.0.1](https://github.com/rpush/rpush/tree/v8.0.0) (2024-09-06)
23
+ ## [v8.0.0](https://github.com/rpush/rpush/tree/v8.0.0) (2024-09-06)
18
24
 
19
25
  **Merged pull requests:**
20
26
 
data/README.md CHANGED
@@ -57,10 +57,9 @@ There is a choice of two modes (and one legacy mode) using certificates or using
57
57
 
58
58
  * `Rpush::Apns2` This requires an annually renewable certificate. see https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns
59
59
  * `Rpush::Apnsp8` This uses encrypted tokens and requires an encryption key id and encryption key (provide as a p8 file). (see https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns)
60
- * `Rpush::Apns` There is also the original APNS (the original version using certificates with a binary underlying protocol over TCP directly rather than over Http/2).
61
60
  Apple have [announced](https://developer.apple.com/news/?id=c88acm2b) that this is not supported after March 31, 2021.
62
61
 
63
- If this is your first time using the APNs, you will need to generate either SSL certificates (for Apns2 or Apns) or an Encryption Key (p8) and an Encryption Key ID (for Apnsp8). See [Generating Certificates](https://github.com/rpush/rpush/wiki/Generating-Certificates) for instructions.
62
+ If this is your first time using the APNs, you will need to generate either SSL certificates (for standard Apns) or an Encryption Key (p8) and an Encryption Key ID (for Apnsp8). See [Generating Certificates](https://github.com/rpush/rpush/wiki/Generating-Certificates) for instructions.
64
63
 
65
64
  ##### Apnsp8
66
65
 
@@ -83,7 +82,7 @@ n = Rpush::Apnsp8::Notification.new
83
82
  n.app = Rpush::Apnsp8::App.find_by_name("ios_app")
84
83
  n.device_token = "..." # hex string
85
84
  n.alert = "hi mom!"
86
- # n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
85
+ # n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
87
86
  n.data = { foo: :bar }
88
87
  n.save!
89
88
  ```
@@ -108,7 +107,7 @@ n = Rpush::Apns2::Notification.new
108
107
  n.app = Rpush::Apns2::App.find_by_name("ios_app")
109
108
  n.device_token = "..." # hex string
110
109
  n.alert = "hi mom!"
111
- # n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
110
+ # n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
112
111
  n.data = {
113
112
  headers: { 'apns-topic': "BUNDLE ID" }, # the bundle id of the app, like com.example.appname. Not necessary if set on the app (see above)
114
113
  foo: :bar
@@ -118,48 +117,24 @@ n.save!
118
117
 
119
118
  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.
120
119
 
121
- ##### Apns (legacy protocol)
122
-
123
- ```ruby
124
- app = Rpush::Apns::App.new
125
- app.name = "ios_app"
126
- app.certificate = File.read("/path/to/sandbox.pem")
127
- app.environment = "development" # APNs environment.
128
- app.password = "certificate password"
129
- app.connections = 1
130
- app.save!
131
- ```
132
-
133
- ```ruby
134
- n = Rpush::Apns::Notification.new
135
- n.app = Rpush::Apns::App.find_by_name("ios_app")
136
- n.device_token = "..." # hex string
137
- n.alert = "hi mom!"
138
- # n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
139
- n.data = { foo: :bar }
140
- n.save!
141
- ```
142
-
143
120
  ##### Safari Push Notifications
144
121
 
145
122
  Using one of the notifications methods above, the `url_args` attribute is available for Safari Push Notifications.
146
123
 
147
124
  ##### Environment
148
125
 
149
- The app `environment` for any Apns* option is "development" for XCode installs, and "production" for app store and TestFlight. Note that for Apns2 you can now use one (production + sandbox) certificate (you don't need a separate "sandbox" or development certificate), but if you do generate a development/sandbox certificate it can only be used for "development". With Apnsp8 tokens, you can target either "development" or "production" environments.
126
+ The app `environment` for any Apns* option is "development" for XCode installs, and "production" for app store and TestFlight. Note that you can now use one (production + sandbox) certificate (you don't need a separate "sandbox" or development certificate), but if you do generate a development/sandbox certificate it can only be used for "development". With Apnsp8 tokens, you can target either "development" or "production" environments.
150
127
 
151
128
  #### Firebase Cloud Messaging
152
129
 
153
- ##### Firebase Cloud Messaging API (V1)
154
-
155
130
  You will need two params to make use of FCM via Rpush.
156
131
  - `firebase_project_id` - The `Project ID` in your Firebase Project Settings
157
132
  - `json_key` - The JSON key file for a service account with the `Firebase Admin SDK Administrator Service Agent` role.
158
133
 
159
- Create service account in the google cloud account attached to your firebase account:
160
- https://console.cloud.google.com/iam-admin/serviceaccounts
161
- Make sure it has Role `Firebase Admin SDK Administrator Service Agent`
162
- Add + Download the json key for the service account.
134
+ Create service account in the google cloud account attached to your firebase account:
135
+ https://console.cloud.google.com/iam-admin/serviceaccounts
136
+ Make sure it has Role `Firebase Admin SDK Administrator Service Agent`
137
+ Add + Download the json key for the service account.
163
138
 
164
139
  Once you have those two params, you can create an FCM app and send notifications.
165
140
 
@@ -180,37 +155,6 @@ n.data = {}.transform_values(&:to_s) # All values going in here have to be strin
180
155
  n.save!
181
156
  ```
182
157
 
183
- ##### Cloud Messaging API (Legacy)
184
-
185
- **Note:** Deprecated on 2023/6/20 and scheduled to be disabled on 2024/6/20.
186
-
187
- FCM and GCM are – as of writing – compatible with each other. See also [this comment](https://github.com/rpush/rpush/issues/284#issuecomment-228330206) for further references.
188
-
189
- Please refer to the Firebase Console on where to find your `auth_key` (probably called _Server Key_ there). To verify you have the right key, use tools like [Postman](https://www.getpostman.com/), [HTTPie](https://httpie.org/), `curl` or similar before reporting a new issue. See also [this comment](https://github.com/rpush/rpush/issues/346#issuecomment-289218776).
190
-
191
- ```ruby
192
- app = Rpush::Gcm::App.new
193
- app.name = "android_app"
194
- app.auth_key = "..."
195
- app.connections = 1
196
- app.save!
197
- ```
198
-
199
- ```ruby
200
- n = Rpush::Gcm::Notification.new
201
- n.app = Rpush::Gcm::App.find_by_name("android_app")
202
- n.registration_ids = ["..."]
203
- n.data = { message: "hi mom!" }
204
- n.priority = 'high' # Optional, can be either 'normal' or 'high'
205
- n.content_available = true # Optional
206
- # Optional notification payload. See the reference below for more keys you can use!
207
- n.notification = { body: 'great match!',
208
- title: 'Portugal vs. Denmark',
209
- icon: 'myicon'
210
- }
211
- n.save!
212
- ```
213
-
214
158
  FCM also requires you to respond to [Canonical IDs](https://github.com/rpush/rpush/wiki/Canonical-IDs).
215
159
 
216
160
  Check the [FCM reference](https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support) for what keys you can use and are available to you. **Note:** Not all are yet implemented in Rpush.
@@ -411,7 +355,6 @@ Rpush will deliver all pending notifications and then exit.
411
355
 
412
356
  ```ruby
413
357
  Rpush.push
414
- Rpush.apns_feedback
415
358
  ```
416
359
 
417
360
  See [Push API](https://github.com/rpush/rpush/wiki/Push-API) for more details.
@@ -30,9 +30,6 @@ Rpush.configure do |config|
30
30
  # If the logger goes to stdout, you can disable foreground logging to avoid duplication.
31
31
  # config.foreground_logging = false
32
32
 
33
- # config.apns.feedback_receiver.enabled = true
34
- # config.apns.feedback_receiver.frequency = 60
35
-
36
33
  end
37
34
 
38
35
  Rpush.reflect do |on|
@@ -76,10 +73,6 @@ Rpush.reflect do |on|
76
73
  # on.notification_id_will_retry do |app, notification_id, retry_after|
77
74
  # end
78
75
 
79
- # Called when a TCP connection is lost and will be reconnected.
80
- # on.tcp_connection_lost do |app, error|
81
- # end
82
-
83
76
  # Called for each recipient which successfully receives a notification. This
84
77
  # can occur more than once for the same notification when there are multiple
85
78
  # recipients.
@@ -88,7 +81,7 @@ Rpush.reflect do |on|
88
81
 
89
82
  # Called for each recipient which fails to receive a notification. This
90
83
  # can occur more than once for the same notification when there are multiple
91
- # recipients. (do not handle invalid registration IDs here)
84
+ # recipients. (do not handle invalid device tokens here)
92
85
  # on.fcm_failed_to_recipient do |notification, error|
93
86
  # end
94
87
 
@@ -100,23 +93,23 @@ Rpush.reflect do |on|
100
93
  # Called for each recipient which successfully receives a notification. This
101
94
  # can occur more than once for the same notification when there are multiple
102
95
  # recipients.
103
- # on.gcm_delivered_to_recipient do |notification, registration_id|
96
+ # on.fcm_delivered_to_recipient do |notification, device_token|
104
97
  # end
105
98
 
106
99
  # Called for each recipient which fails to receive a notification. This
107
100
  # can occur more than once for the same notification when there are multiple
108
- # recipients. (do not handle invalid registration IDs here)
109
- # on.gcm_failed_to_recipient do |notification, error, registration_id|
101
+ # recipients. (do not handle invalid device tokens here)
102
+ # on.fcm_failed_to_recipient do |notification, error, device_token|
110
103
  # end
111
104
 
112
- # Called when the GCM returns a canonical registration ID.
105
+ # Called when the FCM returns a canonical device token.
113
106
  # You will need to replace old_id with canonical_id in your records.
114
- # on.gcm_canonical_id do |old_id, canonical_id|
107
+ # on.fcm_canonical_id do |old_id, canonical_id|
115
108
  # end
116
109
 
117
- # Called when the GCM returns a failure that indicates an invalid registration id.
118
- # You will need to delete the registration_id from your records.
119
- # on.gcm_invalid_registration_id do |app, error, registration_id|
110
+ # Called when the FCM returns a failure that indicates an invalid device token.
111
+ # You will need to delete the device_token from your records.
112
+ # on.fcm_invalid_device_token do |app, error, device_token|
120
113
  # end
121
114
 
122
115
  # Called when an SSL certificate will expire within 1 month.
@@ -25,10 +25,6 @@ require 'rpush/client/active_model/fcm/notification_keys_in_allowed_list_validat
25
25
  require 'rpush/client/active_model/fcm/app'
26
26
  require 'rpush/client/active_model/fcm/notification'
27
27
 
28
- require 'rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator'
29
- require 'rpush/client/active_model/gcm/app'
30
- require 'rpush/client/active_model/gcm/notification'
31
-
32
28
  require 'rpush/client/active_model/wpns/app'
33
29
  require 'rpush/client/active_model/wpns/notification'
34
30
 
@@ -19,9 +19,6 @@ require 'rpush/client/active_record/apnsp8/app'
19
19
  require 'rpush/client/active_record/fcm/notification'
20
20
  require 'rpush/client/active_record/fcm/app'
21
21
 
22
- require 'rpush/client/active_record/gcm/notification'
23
- require 'rpush/client/active_record/gcm/app'
24
-
25
22
  require 'rpush/client/active_record/wpns/notification'
26
23
  require 'rpush/client/active_record/wpns/app'
27
24
 
@@ -30,9 +30,6 @@ require 'rpush/client/redis/apnsp8/notification'
30
30
  require 'rpush/client/redis/fcm/app'
31
31
  require 'rpush/client/redis/fcm/notification'
32
32
 
33
- require 'rpush/client/redis/gcm/app'
34
- require 'rpush/client/redis/gcm/notification'
35
-
36
33
  require 'rpush/client/redis/adm/app'
37
34
  require 'rpush/client/redis/adm/notification'
38
35
 
@@ -16,27 +16,12 @@ module Rpush
16
16
  end
17
17
  end
18
18
 
19
- CURRENT_ATTRS = [:push_poll, :embedded, :pid_file, :batch_size, :push, :client, :logger, :log_file, :foreground, :foreground_logging, :log_level, :plugin, :apns]
19
+ CURRENT_ATTRS = [:push_poll, :embedded, :pid_file, :batch_size, :push, :client, :logger, :log_file, :foreground, :foreground_logging, :log_level, :plugin]
20
20
  DEPRECATED_ATTRS = []
21
21
  CONFIG_ATTRS = CURRENT_ATTRS + DEPRECATED_ATTRS
22
22
 
23
23
  class ConfigurationError < StandardError; end
24
24
 
25
- class ApnsFeedbackReceiverConfiguration < Struct.new(:frequency, :enabled) # rubocop:disable Style/StructInheritance
26
- def initialize
27
- super
28
- self.enabled = true
29
- self.frequency = 60
30
- end
31
- end
32
-
33
- class ApnsConfiguration < Struct.new(:feedback_receiver) # rubocop:disable Style/StructInheritance
34
- def initialize
35
- super
36
- self.feedback_receiver = ApnsFeedbackReceiverConfiguration.new
37
- end
38
- end
39
-
40
25
  class Configuration < Struct.new(*CONFIG_ATTRS) # rubocop:disable Style/StructInheritance
41
26
  include Deprecatable
42
27
 
@@ -55,8 +40,6 @@ module Rpush
55
40
  self.foreground = false
56
41
  self.foreground_logging = true
57
42
 
58
- self.apns = ApnsConfiguration.new
59
-
60
43
  # Internal options.
61
44
  self.embedded = false
62
45
  self.push = false
@@ -106,7 +89,7 @@ module Rpush
106
89
  client_module = Rpush::Client.const_get(client.to_s.camelize)
107
90
  Rpush.send(:include, client_module) unless Rpush.ancestors.include?(client_module)
108
91
 
109
- [:Apns, :Fcm, :Gcm, :Wpns, :Wns, :Adm, :Pushy, :Webpush].each do |service|
92
+ [:Apns, :Fcm, :Wpns, :Wns, :Adm, :Pushy, :Webpush].each do |service|
110
93
  Rpush.const_set(service, client_module.const_get(service)) unless Rpush.const_defined?(service)
111
94
  end
112
95
 
@@ -3,8 +3,6 @@ module Rpush
3
3
  module ServiceConfigMethods
4
4
  DISPATCHERS = {
5
5
  http: Rpush::Daemon::Dispatcher::Http,
6
- tcp: Rpush::Daemon::Dispatcher::Tcp,
7
- apns_tcp: Rpush::Daemon::Dispatcher::ApnsTcp,
8
6
  apns_http2: Rpush::Daemon::Dispatcher::ApnsHttp2,
9
7
  apnsp8_http2: Rpush::Daemon::Dispatcher::Apnsp8Http2
10
8
  }
@@ -138,26 +138,14 @@ module Rpush
138
138
  end
139
139
  end
140
140
 
141
- def create_apns_feedback(failed_at, device_token, app)
142
- with_database_reconnect_and_retry do
143
- Rpush::Client::ActiveRecord::Apns::Feedback.create!(failed_at: failed_at,
144
- device_token: device_token, app_id: app.id)
145
- end
146
- end
147
-
148
141
  def create_fcm_notification(attrs, data, app)
149
142
  notification = Rpush::Client::ActiveRecord::Fcm::Notification.new
150
143
  create_fcm_like_notification(notification, attrs, data, app)
151
144
  end
152
145
 
153
- def create_gcm_notification(attrs, data, registration_ids, deliver_after, app)
154
- notification = Rpush::Client::ActiveRecord::Gcm::Notification.new
155
- create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
156
- end
157
-
158
146
  def create_adm_notification(attrs, data, registration_ids, deliver_after, app)
159
147
  notification = Rpush::Client::ActiveRecord::Adm::Notification.new
160
- create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
148
+ create_adm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
161
149
  end
162
150
 
163
151
  def update_app(app)
@@ -209,7 +197,7 @@ module Rpush
209
197
  end
210
198
  end
211
199
 
212
- def create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app) # rubocop:disable Metrics/ParameterLists
200
+ def create_adm_like_notification(notification, attrs, data, registration_ids, deliver_after, app) # rubocop:disable Metrics/ParameterLists
213
201
  with_database_reconnect_and_retry do
214
202
  notification.assign_attributes(attrs)
215
203
  notification.data = data
@@ -4,8 +4,8 @@ module Rpush
4
4
  class Interface
5
5
  PUBLIC_METHODS = [:deliverable_notifications, :mark_retryable,
6
6
  :mark_batch_retryable, :mark_delivered, :mark_batch_delivered,
7
- :mark_failed, :mark_batch_failed, :create_apns_feedback,
8
- :create_fcm_notification, :create_gcm_notification, :create_adm_notification,
7
+ :mark_failed, :mark_batch_failed,
8
+ :create_fcm_notification, :create_adm_notification,
9
9
  :update_app, :update_notification, :release_connection,
10
10
  :all_apps, :app, :mark_ids_failed, :mark_ids_retryable,
11
11
  :reopen_log, :pending_delivery_count, :translate_integer_notification_id]
@@ -88,23 +88,14 @@ module Rpush
88
88
  end
89
89
  end
90
90
 
91
- def create_apns_feedback(failed_at, device_token, app)
92
- Rpush::Client::Redis::Apns::Feedback.create!(failed_at: failed_at, device_token: device_token, app_id: app.id)
93
- end
94
-
95
91
  def create_fcm_notification(attrs, data, app)
96
92
  notification = Rpush::Client::Redis::Fcm::Notification.new
97
93
  create_fcm_like_notification(notification, attrs, data, app)
98
94
  end
99
95
 
100
- def create_gcm_notification(attrs, data, registration_ids, deliver_after, app)
101
- notification = Rpush::Client::Redis::Gcm::Notification.new
102
- create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
103
- end
104
-
105
96
  def create_adm_notification(attrs, data, registration_ids, deliver_after, app)
106
97
  notification = Rpush::Client::Redis::Adm::Notification.new
107
- create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
98
+ create_adm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
108
99
  end
109
100
 
110
101
  def update_app(app)
@@ -151,7 +142,7 @@ module Rpush
151
142
  notification
152
143
  end
153
144
 
154
- def create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app) # rubocop:disable Metrics/ParameterLists
145
+ def create_adm_like_notification(notification, attrs, data, registration_ids, deliver_after, app) # rubocop:disable Metrics/ParameterLists
155
146
  notification.assign_attributes(attrs)
156
147
  notification.data = data
157
148
  notification.registration_ids = registration_ids
data/lib/rpush/daemon.rb CHANGED
@@ -19,11 +19,8 @@ require 'rpush/daemon/batch'
19
19
  require 'rpush/daemon/queue_payload'
20
20
  require 'rpush/daemon/synchronizer'
21
21
  require 'rpush/daemon/app_runner'
22
- require 'rpush/daemon/tcp_connection'
23
22
  require 'rpush/daemon/dispatcher_loop'
24
23
  require 'rpush/daemon/dispatcher/http'
25
- require 'rpush/daemon/dispatcher/tcp'
26
- require 'rpush/daemon/dispatcher/apns_tcp'
27
24
  require 'rpush/daemon/dispatcher/apns_http2'
28
25
  require 'rpush/daemon/dispatcher/apnsp8_http2'
29
26
  require 'rpush/daemon/service_config_methods'
@@ -38,10 +35,6 @@ require 'rpush/daemon/rpc/client'
38
35
 
39
36
  require 'rpush/daemon/store/interface'
40
37
 
41
- require 'rpush/daemon/apns/delivery'
42
- require 'rpush/daemon/apns/feedback_receiver'
43
- require 'rpush/daemon/apns'
44
-
45
38
  require 'rpush/daemon/apns2/delivery'
46
39
  require 'rpush/daemon/apns2'
47
40
 
@@ -53,9 +46,6 @@ require 'rpush/daemon/fcm/delivery'
53
46
  require 'rpush/daemon/fcm'
54
47
  require 'rpush/daemon/google_credential_cache'
55
48
 
56
- require 'rpush/daemon/gcm/delivery'
57
- require 'rpush/daemon/gcm'
58
-
59
49
  require 'rpush/daemon/wpns/delivery'
60
50
  require 'rpush/daemon/wpns'
61
51
 
@@ -5,10 +5,9 @@ module Rpush
5
5
  REFLECTIONS = [
6
6
  :apns_feedback, :notification_enqueued, :notification_delivered,
7
7
  :notification_failed, :notification_will_retry,
8
- :gcm_delivered_to_recipient, :gcm_failed_to_recipient, :gcm_canonical_id, :gcm_invalid_registration_id,
9
8
  :fcm_delivered_to_recipient, :fcm_failed_to_recipient, :fcm_canonical_id, :fcm_invalid_device_token,
10
9
  :error, :adm_canonical_id, :adm_failed_to_recipient, :wns_invalid_channel,
11
- :tcp_connection_lost, :ssl_certificate_will_expire, :ssl_certificate_revoked,
10
+ :ssl_certificate_will_expire, :ssl_certificate_revoked,
12
11
  :notification_id_will_retry, :notification_id_failed
13
12
  ]
14
13
 
data/lib/rpush/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Rpush
2
2
  module VERSION
3
- MAJOR = 8
3
+ MAJOR = 9
4
4
  MINOR = 0
5
5
  TINY = 0
6
6
  PRE = nil
data/lib/rpush.rb CHANGED
@@ -20,7 +20,6 @@ require 'rpush/reflectable'
20
20
  require 'rpush/plugin'
21
21
  require 'rpush/embed'
22
22
  require 'rpush/push'
23
- require 'rpush/apns_feedback'
24
23
 
25
24
  module Rpush
26
25
  def self.jruby?
@@ -2,31 +2,57 @@ require 'functional_spec_helper'
2
2
 
3
3
  describe Rpush::CLI do
4
4
  def create_app
5
- app = Rpush::Apns::App.new
5
+ app = Rpush::Apns2::App.new
6
6
  app.certificate = TEST_CERT
7
7
  app.name = 'test'
8
- app.environment = 'sandbox'
8
+ app.environment = 'development'
9
+ app.bundle_id = 'com.example.app'
9
10
  app.save!
10
11
  app
11
12
  end
12
13
 
13
- describe 'status' do
14
- let(:tcp_socket) { double(TCPSocket, setsockopt: nil, close: nil) }
15
- let(:ssl_socket) { double(OpenSSL::SSL::SSLSocket, :sync= => nil, connect: nil, write: nil, flush: nil, read: nil, close: nil) }
16
- let(:io_double) { double(select: nil) }
14
+ let(:fake_client) {
15
+ double(
16
+ prepare_request: fake_http2_request,
17
+ close: 'ok',
18
+ call_async: 'ok',
19
+ join: 'ok',
20
+ on: 'ok'
21
+ )
22
+ }
23
+ let(:fake_http2_request) { double }
24
+ let(:fake_http_resp_headers) {
25
+ {
26
+ ":status" => "200",
27
+ "apns-id"=>"C6D65840-5E3F-785A-4D91-B97D305C12F6"
28
+ }
29
+ }
30
+ let(:fake_http_resp_body) { '' }
17
31
 
18
- before do
19
- create_app
20
- stub_tcp_connection(tcp_socket, ssl_socket, io_double)
21
- Rpush.embed
32
+ before do
33
+ create_app
34
+ Rpush.config.push_poll = 0.5
22
35
 
23
- timeout do
24
- Thread.pass until File.exist?(Rpush::Daemon::Rpc.socket_path)
25
- end
26
- end
36
+ allow(NetHttp2::Client).
37
+ to receive(:new).and_return(fake_client)
38
+ allow(fake_http2_request).
39
+ to receive(:on).with(:headers).
40
+ and_yield(fake_http_resp_headers)
41
+ allow(fake_http2_request).
42
+ to receive(:on).with(:body_chunk).
43
+ and_yield(fake_http_resp_body)
44
+ allow(fake_http2_request).
45
+ to receive(:on).with(:close).
46
+ and_yield
47
+
48
+ Rpush.embed
49
+ end
27
50
 
28
- after { timeout { Rpush.shutdown } }
51
+ after do
52
+ timeout { Rpush.shutdown }
53
+ end
29
54
 
55
+ describe 'status' do
30
56
  it 'prints the status' do
31
57
  expect(subject).to receive(:configure_rpush) { true }
32
58
  expect(subject).to receive(:puts).with(/app_runners:/)
@@ -1,49 +1,80 @@
1
1
  require 'functional_spec_helper'
2
2
 
3
3
  describe 'embedding' do
4
- let(:timeout) { 10 }
5
- let(:app) { Rpush::Apns::App.new }
6
- let(:notification) { Rpush::Apns::Notification.new }
7
- let(:tcp_socket) { double(TCPSocket, setsockopt: nil, close: nil) }
8
- let(:ssl_socket) { double(OpenSSL::SSL::SSLSocket, :sync= => nil, connect: nil, write: nil, flush: nil, read: nil, close: nil) }
9
- let(:io_double) { double(select: nil) }
10
-
11
- before do
4
+ def create_app
5
+ app = Rpush::Apns2::App.new
12
6
  app.certificate = TEST_CERT
13
7
  app.name = 'test'
14
- app.environment = 'sandbox'
8
+ app.environment = 'development'
9
+ app.bundle_id = 'com.example.app'
15
10
  app.save!
11
+ app
12
+ end
16
13
 
14
+ let(:fake_device_token) { 'a' * 108 }
15
+ let(:notification_data) { nil }
16
+
17
+ def create_notification(app)
18
+ notification = Rpush::Apns2::Notification.new
17
19
  notification.app = app
20
+ notification.sound = 'default'
18
21
  notification.alert = 'test'
19
- notification.device_token = 'a' * 108
22
+ notification.device_token = fake_device_token
23
+ notification.data = notification_data
24
+ notification.content_available = 1
20
25
  notification.save!
21
-
22
- stub_tcp_connection
26
+ notification
23
27
  end
24
28
 
25
- def stub_tcp_connection
26
- allow_any_instance_of(Rpush::Daemon::TcpConnection).to receive_messages(connect_socket: [tcp_socket, ssl_socket])
27
- allow_any_instance_of(Rpush::Daemon::TcpConnection).to receive_messages(setup_ssl_context: double.as_null_object)
28
- stub_const('Rpush::Daemon::TcpConnection::IO', io_double)
29
- allow(Rpush::Daemon::Apns::FeedbackReceiver).to receive_messages(new: double.as_null_object)
30
- end
29
+ let(:app) { create_app }
30
+ let(:notification) { create_notification(app) }
31
+
32
+ let(:fake_client) {
33
+ double(
34
+ prepare_request: fake_http2_request,
35
+ close: 'ok',
36
+ call_async: 'ok',
37
+ join: 'ok',
38
+ on: 'ok'
39
+ )
40
+ }
41
+ let(:fake_http2_request) { double }
42
+ let(:fake_http_resp_headers) {
43
+ {
44
+ ":status" => "200",
45
+ "apns-id"=>"C6D65840-5E3F-785A-4D91-B97D305C12F6"
46
+ }
47
+ }
48
+ let(:fake_http_resp_body) { '' }
31
49
 
32
50
  before do
33
- Rpush.config.push_poll = 5
51
+ Rpush.config.push_poll = 0.5
52
+
53
+ allow(NetHttp2::Client).
54
+ to receive(:new).and_return(fake_client)
55
+ allow(fake_http2_request).
56
+ to receive(:on).with(:headers).
57
+ and_yield(fake_http_resp_headers)
58
+ allow(fake_http2_request).
59
+ to receive(:on).with(:body_chunk).
60
+ and_yield(fake_http_resp_body)
61
+ allow(fake_http2_request).
62
+ to receive(:on).with(:close).
63
+ and_yield
64
+
34
65
  Rpush.embed
35
66
  end
36
67
 
68
+ after do
69
+ timeout { Rpush.shutdown }
70
+ end
71
+
37
72
  it 'delivers a notification successfully' do
38
73
  expect do
39
- Timeout.timeout(timeout) do
40
- until notification.delivered
41
- notification.reload
42
- sleep 0.1
43
- end
74
+ until notification.delivered
75
+ notification.reload
76
+ sleep 0.1
44
77
  end
45
78
  end.to change(notification, :delivered).to(true)
46
79
  end
47
-
48
- after { Timeout.timeout(timeout) { Rpush.shutdown } }
49
80
  end