action_push_native 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/jobs/action_push_native/notification_job.rb +1 -1
- data/app/models/action_push_native/device.rb +2 -2
- data/app/models/action_push_native/record.rb +9 -0
- data/lib/action_push_native/errors.rb +1 -0
- data/lib/action_push_native/service/apns.rb +4 -5
- data/lib/action_push_native/service/fcm.rb +4 -5
- data/lib/action_push_native/service/network_error_handling.rb +1 -1
- data/lib/action_push_native/version.rb +1 -1
- data/lib/action_push_native.rb +8 -1
- data/lib/generators/action_push_native/install/templates/config/push.yml.tt +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 221069cb3459cd2c07eaa4d7a3d2c98c741f2817a15a47cf27e8bc4ea6dd93fb
|
|
4
|
+
data.tar.gz: 5719b281f487a336d96100213946fa41ce8115a573cb1888cfe0eb4422c97bb6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d308c3a5d4a6d721bfe60a09d4f3dc0fdce3c7058ecfc82ed7dfd050b10b121adeadbd89ed48b843bd53a52a62b53fc958d6fd5191b666c83441d8ae51735e62
|
|
7
|
+
data.tar.gz: b782ef4aac0fca069a82415cdb278c1fb5d162a3608f8cede1404934dd859583b7a54b55880925c1e12016e776b734dab352ebbb8ba31b2e95cbf1c3a31c9d3e
|
|
@@ -40,7 +40,7 @@ module ActionPushNative
|
|
|
40
40
|
|
|
41
41
|
with_options retry_options do
|
|
42
42
|
retry_on TimeoutError, wait: 1.minute
|
|
43
|
-
retry_on ConnectionError,
|
|
43
|
+
retry_on ConnectionError, ConnectionPoolTimeoutError, attempts: 20
|
|
44
44
|
|
|
45
45
|
# Altough unexpected, these are short-lived errors that can be retried most of the times.
|
|
46
46
|
retry_on ForbiddenError, BadRequestError
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module ActionPushNative
|
|
4
|
-
class Device <
|
|
4
|
+
class Device < Record
|
|
5
5
|
include ActiveSupport::Rescuable
|
|
6
6
|
|
|
7
7
|
rescue_from(TokenError) { destroy! }
|
|
8
8
|
|
|
9
9
|
belongs_to :owner, polymorphic: true, optional: true
|
|
10
10
|
|
|
11
|
-
enum :platform, { apple: "apple", google: "google" }
|
|
11
|
+
enum :platform, { apple: "apple", google: "google" }, validate: true
|
|
12
12
|
|
|
13
13
|
def push(notification)
|
|
14
14
|
notification.token = token
|
|
@@ -5,9 +5,6 @@ module ActionPushNative
|
|
|
5
5
|
class Apns
|
|
6
6
|
include NetworkErrorHandling
|
|
7
7
|
|
|
8
|
-
# Per-application HTTPX session
|
|
9
|
-
cattr_accessor :httpx_sessions
|
|
10
|
-
|
|
11
8
|
def initialize(config)
|
|
12
9
|
@config = config
|
|
13
10
|
end
|
|
@@ -59,9 +56,11 @@ module ActionPushNative
|
|
|
59
56
|
payload.compact
|
|
60
57
|
end
|
|
61
58
|
|
|
59
|
+
HTTPX_SESSIONS_KEY = :action_push_native_apns_httpx_sessions
|
|
60
|
+
|
|
62
61
|
def httpx_session
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
ActiveSupport::IsolatedExecutionState[HTTPX_SESSIONS_KEY] ||= {}
|
|
63
|
+
ActiveSupport::IsolatedExecutionState[HTTPX_SESSIONS_KEY][config] ||= HttpxSession.new(config)
|
|
65
64
|
end
|
|
66
65
|
|
|
67
66
|
def handle_error(response)
|
|
@@ -5,9 +5,6 @@ module ActionPushNative
|
|
|
5
5
|
class Fcm
|
|
6
6
|
include NetworkErrorHandling
|
|
7
7
|
|
|
8
|
-
# Per-application HTTPX session
|
|
9
|
-
cattr_accessor :httpx_sessions
|
|
10
|
-
|
|
11
8
|
def initialize(config)
|
|
12
9
|
@config = config
|
|
13
10
|
end
|
|
@@ -20,9 +17,11 @@ module ActionPushNative
|
|
|
20
17
|
private
|
|
21
18
|
attr_reader :config
|
|
22
19
|
|
|
20
|
+
HTTPX_SESSIONS_KEY = :action_push_native_fcm_httpx_sessions
|
|
21
|
+
|
|
23
22
|
def httpx_session
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
ActiveSupport::IsolatedExecutionState[HTTPX_SESSIONS_KEY] ||= {}
|
|
24
|
+
ActiveSupport::IsolatedExecutionState[HTTPX_SESSIONS_KEY][config] ||= HttpxSession.new(config)
|
|
26
25
|
end
|
|
27
26
|
|
|
28
27
|
def payload_from(notification)
|
|
@@ -4,7 +4,7 @@ module ActionPushNative::Service::NetworkErrorHandling
|
|
|
4
4
|
def handle_network_error(error)
|
|
5
5
|
case error
|
|
6
6
|
when HTTPX::PoolTimeoutError
|
|
7
|
-
raise error
|
|
7
|
+
raise ActionPushNative::ConnectionPoolTimeoutError, error.message
|
|
8
8
|
when Errno::ETIMEDOUT, HTTPX::TimeoutError
|
|
9
9
|
raise ActionPushNative::TimeoutError, error.message
|
|
10
10
|
when Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::EHOSTUNREACH,
|
data/lib/action_push_native.rb
CHANGED
|
@@ -27,7 +27,7 @@ module ActionPushNative
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def self.config_for(platform, notification)
|
|
30
|
-
platform_config =
|
|
30
|
+
platform_config = config[platform.to_sym]
|
|
31
31
|
raise "ActionPushNative: '#{platform}' platform is not configured" unless platform_config.present?
|
|
32
32
|
|
|
33
33
|
if notification.application.present?
|
|
@@ -38,6 +38,13 @@ module ActionPushNative
|
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
def self.config
|
|
42
|
+
path = Rails.application.paths["config/push"].existent.first
|
|
43
|
+
raise "ActionPushNative: config/push.yml not found" unless path
|
|
44
|
+
|
|
45
|
+
Rails.application.config_for(Pathname.new(path))
|
|
46
|
+
end
|
|
47
|
+
|
|
41
48
|
def self.deprecator
|
|
42
49
|
@deprecator ||= ActiveSupport::Deprecation.new
|
|
43
50
|
end
|
|
@@ -11,7 +11,7 @@ shared:
|
|
|
11
11
|
topic: your.bundle.identifier
|
|
12
12
|
|
|
13
13
|
# Set this to the number of threads used to process notifications (default: 5).
|
|
14
|
-
# When the pool size is too small a
|
|
14
|
+
# When the pool size is too small a ConnectionPoolTimeoutError will be raised.
|
|
15
15
|
# connection_pool_size: 5
|
|
16
16
|
|
|
17
17
|
# Change the request timeout (default: 30).
|
|
@@ -21,7 +21,7 @@ shared:
|
|
|
21
21
|
# Please note that anything built directly from Xcode and loaded on your phone will have
|
|
22
22
|
# the app generate DEVELOPMENT tokens, while everything else (TestFlight, Apple Store, ...)
|
|
23
23
|
# will be considered as PRODUCTION environment.
|
|
24
|
-
# connect_to_development_server:
|
|
24
|
+
# connect_to_development_server: <%%= Rails.env.development? %>
|
|
25
25
|
|
|
26
26
|
# Use bin/rails credentials:edit to set the fcm secrets (as action_push_native:fcm:encryption_key)
|
|
27
27
|
google:
|
|
@@ -33,7 +33,7 @@ shared:
|
|
|
33
33
|
project_id: your_project_id
|
|
34
34
|
|
|
35
35
|
# Set this to the number of threads used to process notifications (default: 5).
|
|
36
|
-
# When the pool size is too small a
|
|
36
|
+
# When the pool size is too small a ConnectionPoolTimeoutError will be raised.
|
|
37
37
|
# connection_pool_size: 5
|
|
38
38
|
|
|
39
39
|
# Change the request timeout (default: 15).
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: action_push_native
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jacopo Beschi
|
|
@@ -105,6 +105,7 @@ files:
|
|
|
105
105
|
- Rakefile
|
|
106
106
|
- app/jobs/action_push_native/notification_job.rb
|
|
107
107
|
- app/models/action_push_native/device.rb
|
|
108
|
+
- app/models/action_push_native/record.rb
|
|
108
109
|
- db/migrate/20250610075650_create_action_push_native_device.rb
|
|
109
110
|
- lib/action_push_native.rb
|
|
110
111
|
- lib/action_push_native/configured_notification.rb
|
|
@@ -145,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
145
146
|
- !ruby/object:Gem::Version
|
|
146
147
|
version: '0'
|
|
147
148
|
requirements: []
|
|
148
|
-
rubygems_version:
|
|
149
|
+
rubygems_version: 4.0.3
|
|
149
150
|
specification_version: 4
|
|
150
151
|
summary: Send push notifications to mobile apps
|
|
151
152
|
test_files: []
|