apnotic 1.4.1 → 1.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3e07860f9233dc0f123731853e0a42d899497109
4
- data.tar.gz: 6f484d9d537511e2d7a5cd0a8ef75e58dfa87514
2
+ SHA256:
3
+ metadata.gz: 5ae71d53585d79f023006333f32688ff88ccf7ae92c3c639831ece42a05a2de3
4
+ data.tar.gz: a4b9ba46513dfb766c303d9ba72ad99e0db0122258967414f34e7c0236aa53bc
5
5
  SHA512:
6
- metadata.gz: 7acc4f79fb3fa12b3ebb98c2cecafb5cb17d12ce70fb649a2a20d0736d5c2cab7068d6ab466f23c03aaa5ba64c2b4a7502090c5f09b73c07c62ec78e5373a697
7
- data.tar.gz: d1930a1051eff9affaf1ad619d55165cf92e92689892a0d2e41453d75bad9f714eeeeb18be612f519433b285368d8272f9f37bb8c9bbbc4921f49ca7444fa6d9
6
+ metadata.gz: 55d81b9a2d59f19f6725cc1f7f163769123b91bfe84a4b1517810d6c8f3f6b533a12e66c535f9337a81356957c426388eb361551075b646d6b1ac34e61145e89
7
+ data.tar.gz: 6ee59aada3067fc897c259d9a8c41c6fd94c6ac68e3d1e2e7bed402aa7284bdf51fe67dad7a428f4583fe82257b85e06bf680320d3c57e8bd2d12cca8da172b1
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.1
data/.travis.yml CHANGED
@@ -1,11 +1,14 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1
4
- - 2.2
5
3
  - 2.3
6
4
  - 2.4
7
5
  - 2.5
6
+ - 2.6
7
+ - 2.7
8
8
 
9
9
  branches:
10
10
  only:
11
11
  - master
12
+
13
+ before_install:
14
+ - gem install bundler
data/README.md CHANGED
@@ -86,7 +86,7 @@ end
86
86
  connection.push_async(push)
87
87
 
88
88
  # wait for all requests to be completed
89
- connection.join
89
+ connection.join(timeout: 5)
90
90
 
91
91
  # close the connection
92
92
  connection.close
@@ -207,6 +207,10 @@ Apnotic::Connection.new(options)
207
207
  | :cert_pass | Optional. The certificate's password.
208
208
  | :url | Optional. Defaults to https://api.push.apple.com:443.
209
209
  | :connect_timeout | Optional. Expressed in seconds, defaults to 30.
210
+ | :proxy_addr | Optional. Proxy server. e.g. http://proxy.example.com
211
+ | :proxy_port | Optional. Proxy port. e.g. 8080
212
+ | :proxy_user | Optional. User name for proxy authentication. e.g. user_name
213
+ | :proxy_pass | Optional. Password for proxy authentication. e.g. pass_word
210
214
 
211
215
  Note that since `:cert_path` can be any object that responds to `:read`, it is possible to pass in a certificate string directly by wrapping it up in a `StringIO` object:
212
216
 
@@ -311,6 +315,9 @@ These are all Accessor attributes.
311
315
  | `category` | "
312
316
  | `custom_payload` | "
313
317
  | `thread_id` | "
318
+ | `target_content_id` | "
319
+ | `interruption_level` | Refer to [Payload Key Reference](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2943363) for details. iOS 15+
320
+ | `relevance_score` | Refer to [Payload Key Reference](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2943363) for details. iOS 15+
314
321
  | `apns_id` | Refer to [Communicating with APNs](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html) for details.
315
322
  | `expiration` | "
316
323
  | `priority` | "
data/apnotic.gemspec CHANGED
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "net-http2", ">= 0.18", "< 2"
22
- spec.add_dependency "connection_pool", "~> 2.0"
21
+ spec.add_dependency "net-http2", ">= 0.18.3", "< 2"
22
+ spec.add_dependency "connection_pool", "~> 2"
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.3"
25
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "rake", ">= 12.3.3"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  end
@@ -26,6 +26,10 @@ module Apnotic
26
26
  authorization ? "bearer #{authorization}" : nil
27
27
  end
28
28
 
29
+ def background_notification?
30
+ false
31
+ end
32
+
29
33
  private
30
34
 
31
35
  def to_hash
@@ -5,6 +5,7 @@ module Apnotic
5
5
 
6
6
  APPLE_DEVELOPMENT_SERVER_URL = "https://api.sandbox.push.apple.com:443"
7
7
  APPLE_PRODUCTION_SERVER_URL = "https://api.push.apple.com:443"
8
+ PROXY_SETTINGS_KEYS = [:proxy_addr, :proxy_port, :proxy_user, :proxy_pass]
8
9
 
9
10
  class Connection
10
11
  attr_reader :url, :cert_path
@@ -28,7 +29,15 @@ module Apnotic
28
29
 
29
30
  raise "Cert file not found: #{@cert_path}" unless @cert_path && (@cert_path.respond_to?(:read) || File.exist?(@cert_path))
30
31
 
31
- @client = NetHttp2::Client.new(@url, ssl_context: ssl_context, connect_timeout: @connect_timeout)
32
+ http2_options = {
33
+ ssl_context: ssl_context,
34
+ connect_timeout: @connect_timeout
35
+ }
36
+ PROXY_SETTINGS_KEYS.each do |key|
37
+ http2_options[key] = options[key] if options[key]
38
+ end
39
+
40
+ @client = NetHttp2::Client.new(@url, http2_options)
32
41
  end
33
42
 
34
43
  def push(notification, options={})
@@ -63,8 +72,8 @@ module Apnotic
63
72
  @client.close
64
73
  end
65
74
 
66
- def join
67
- @client.join
75
+ def join(timeout: nil)
76
+ @client.join(timeout: timeout)
68
77
  end
69
78
 
70
79
  def on(event, &block)
@@ -92,7 +101,7 @@ module Apnotic
92
101
  def remote_max_concurrent_streams
93
102
  # 0x7fffffff is the default value from http-2 gem (2^31)
94
103
  if @client.remote_settings[:settings_max_concurrent_streams] == 0x7fffffff
95
- 0
104
+ 1
96
105
  else
97
106
  @client.remote_settings[:settings_max_concurrent_streams]
98
107
  end
@@ -4,6 +4,11 @@ module Apnotic
4
4
 
5
5
  class Notification < AbstractNotification
6
6
  attr_accessor :alert, :badge, :sound, :content_available, :category, :custom_payload, :url_args, :mutable_content, :thread_id
7
+ attr_accessor :target_content_id, :interruption_level, :relevance_score
8
+
9
+ def background_notification?
10
+ aps.count == 1 && aps.key?('content-available') && aps['content-available'] == 1
11
+ end
7
12
 
8
13
  private
9
14
 
@@ -17,6 +22,9 @@ module Apnotic
17
22
  result.merge!('url-args' => url_args) if url_args
18
23
  result.merge!('mutable-content' => mutable_content) if mutable_content
19
24
  result.merge!('thread-id' => thread_id) if thread_id
25
+ result.merge!('target-content-id' => target_content_id) if target_content_id
26
+ result.merge!('interruption-level' => interruption_level) if interruption_level
27
+ result.merge!('relevance-score' => relevance_score) if relevance_score
20
28
  end
21
29
  end
22
30
 
@@ -16,6 +16,7 @@ module Apnotic
16
16
  h.merge!('apns-id' => notification.apns_id) if notification.apns_id
17
17
  h.merge!('apns-expiration' => notification.expiration) if notification.expiration
18
18
  h.merge!('apns-priority' => notification.priority) if notification.priority
19
+ h.merge!('apns-push-type' => notification.background_notification? ? 'background' : 'alert' )
19
20
  h.merge!('apns-topic' => notification.topic) if notification.topic
20
21
  h.merge!('apns-collapse-id' => notification.apns_collapse_id) if notification.apns_collapse_id
21
22
  h.merge!('authorization' => notification.authorization_header) if notification.authorization_header
@@ -1,3 +1,3 @@
1
1
  module Apnotic
2
- VERSION = '1.4.1'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apnotic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Ostinelli
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-18 00:00:00.000000000 Z
11
+ date: 2021-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http2
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.18'
19
+ version: 0.18.3
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '0.18'
29
+ version: 0.18.3
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2'
@@ -36,42 +36,42 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.0'
39
+ version: '2'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '2.0'
46
+ version: '2'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '1.3'
53
+ version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '1.3'
60
+ version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: '10.0'
67
+ version: 12.3.3
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '10.0'
74
+ version: 12.3.3
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -86,7 +86,7 @@ dependencies:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '3.0'
89
- description:
89
+ description:
90
90
  email:
91
91
  - roberto@ostinelli.net
92
92
  executables: []
@@ -95,8 +95,7 @@ extra_rdoc_files: []
95
95
  files:
96
96
  - ".gitignore"
97
97
  - ".rspec"
98
- - ".ruby-gemset"
99
- - ".ruby-version"
98
+ - ".tool-versions"
100
99
  - ".travis.yml"
101
100
  - Gemfile
102
101
  - LICENSE.md
@@ -121,7 +120,7 @@ homepage: http://github.com/ostinelli/apnotic
121
120
  licenses:
122
121
  - MIT
123
122
  metadata: {}
124
- post_install_message:
123
+ post_install_message:
125
124
  rdoc_options: []
126
125
  require_paths:
127
126
  - lib
@@ -136,9 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
135
  - !ruby/object:Gem::Version
137
136
  version: '0'
138
137
  requirements: []
139
- rubyforge_project:
140
- rubygems_version: 2.6.14
141
- signing_key:
138
+ rubygems_version: 3.1.2
139
+ signing_key:
142
140
  specification_version: 4
143
141
  summary: Apnotic is an Apple Push Notification gem able to provide instant feedback.
144
142
  test_files: []
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- apnotic
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.3.1