ts_p8push 1.0.8 → 1.0.9

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
2
  SHA256:
3
- metadata.gz: 21b146e5570c44da7ac9d83ec7a92369e8d492b0b73f4b904c68b930dfbc292a
4
- data.tar.gz: 5892d8c28149654cc7837f58a5e6c06d4e5c8caed943015f38b3b177b0e62732
3
+ metadata.gz: ef00369583da57c6a37bc90bee3a2faacdbe2f3aa6b9f97cc778495ae9b7f22d
4
+ data.tar.gz: 1714c119948a3c9189fa4f7581213eae29ed1eb51357aad690dae04e5aa0b0b7
5
5
  SHA512:
6
- metadata.gz: 9ed70ae53f445edd9c08ebba0badd42e976cc61947768544da6eccd897b11daaae4aff9c0d8906ac63cb554c13687e641d9f5a91155ea8eb625cc8e6366ccb6f
7
- data.tar.gz: b2f3dc802065944d3f3cc0724924bb88b70b54eabadc7865dc6393e679c4cf0090f6e6798c0eb64ffe913f326be15ec81980921a709f3a419afadf0eeb483b8b
6
+ metadata.gz: c5b6df0eb81504e649f7cbda63ba0543ad794b842a8ae730bffd2e5961f3f302faf68d6055b162240de25b0cc0ee6657233198402dd9a802e9cd67ac24ae0281
7
+ data.tar.gz: 16862c58308ce5b9b0aa7cd75dcd67beec12c957df06cbc65e3c9bee850c9ea441db0b35879c373d3315cefa829daf04de04f0d4701eb85124029c2b8f4e16bc
data/lib/p8push/client.rb CHANGED
@@ -27,7 +27,7 @@ module P8push
27
27
  @private_key = private_key || File.read(ENV['APN_PRIVATE_KEY'])
28
28
  @team_id = team_id || ENV['APN_TEAM_ID']
29
29
  @key_id = key_id || ENV['APN_KEY_ID']
30
- @timeout = timeout || Float(ENV['APN_TIMEOUT'] || 2.0)
30
+ @timeout = Float(timeout || ENV['APN_TIMEOUT'] || 2.0) rescue 2.0
31
31
  end
32
32
 
33
33
  def jwt_http2_post(topic, payload, token)
@@ -38,6 +38,7 @@ module P8push
38
38
  h['apns-expiration'] = '0'
39
39
  h['apns-priority'] = '10'
40
40
  h['apns-topic'] = topic
41
+ h['scheme'] = 'https'
41
42
  h['authorization'] = "bearer #{jwt_token}"
42
43
  h['content-type'] = 'application/json'
43
44
  res = client.call(:post, '/3/device/'+token, body: payload.to_json, timeout: @timeout,
@@ -29,7 +29,7 @@ module P8push
29
29
  MAXIMUM_PAYLOAD_SIZE = 2048
30
30
 
31
31
  attr_accessor :topic, :token, :alert, :badge, :sound, :category, :content_available, :mutable_content,
32
- :custom_data, :id, :expiry, :priority
32
+ :custom_data, :id, :expiry, :priority, :title, :body
33
33
  attr_reader :sent_at
34
34
  attr_writer :apns_error_code
35
35
 
@@ -39,6 +39,8 @@ module P8push
39
39
  def initialize(options = {})
40
40
  @token = options.delete(:token) || options.delete(:device)
41
41
  @alert = options.delete(:alert)
42
+ @title = options.delete(:title)
43
+ @body = options.delete(:body)
42
44
  @topic = options.delete(:topic) || ENV['APN_BUNDLE_ID']
43
45
  @badge = options.delete(:badge)
44
46
  @sound = options.delete(:sound)
@@ -56,7 +58,8 @@ module P8push
56
58
  json = {}.merge(@custom_data || {}).inject({}) { |h, (k, v)| h[k.to_s] = v; h }
57
59
 
58
60
  json['aps'] ||= {}
59
- json['aps']['alert'] = @alert if @alert
61
+ # json['aps']['alert'] = @alert if @alert
62
+ json['aps']['alert'] = {'title': @title, 'body': @body}
60
63
  json['aps']['badge'] = @badge.to_i rescue 0 if @badge
61
64
  json['aps']['sound'] = @sound if @sound
62
65
  json['aps']['category'] = @category if @category
@@ -1,3 +1,3 @@
1
1
  module P8push
2
- VERSION = '1.0.8'
2
+ VERSION = '1.0.9'
3
3
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ts_p8push
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Arrow
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-06-02 00:00:00.000000000 Z
14
+ date: 2021-06-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: jwt
@@ -86,6 +86,7 @@ files:
86
86
  - "./lib/ts_p8push.rb"
87
87
  - "./p8push.gemspec"
88
88
  - "./ts_p8push-1.0.7.gem"
89
+ - "./ts_p8push-1.0.8.gem"
89
90
  homepage: https://talhashoaib.me
90
91
  licenses:
91
92
  - MIT