moromi-apns 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 14012dd65e5b6265304bd4ee0737e62707ecefb4
4
- data.tar.gz: 51758a1bb050dba730f0f2f39e6047b835ec5d60
2
+ SHA256:
3
+ metadata.gz: 7167115397099f248dacc3e339163dbeca387c1c6e20a88d57ad5596016e4621
4
+ data.tar.gz: b323d8a27c118420e035022aadc39078e174ccd7096dd815e78ad23cc9187d86
5
5
  SHA512:
6
- metadata.gz: d8df04227d01082514d138eac5d56400aca8af2b2ef49d352c4031d86e3bdcf9d4497debb912cadd0efb201db7763fb7c03ae9d22c5c01aeff340a7d35cf748e
7
- data.tar.gz: 265fd58ab3b76cda58ffa5be5f64e4de4bb78b8ce7e6551dbdd2e74a3df8a226f5982057c449375616ce0135f1f8481763c730971e54021fbf00234c1129ea92
6
+ metadata.gz: 212fc3336d785239c6e3622e4d1a0be0d42e18e5ee66cc65b419f12ec889c819d6fc82c9218c033d9fcc1a04eda90a8c2c498d96bc0a2d67a57a54a6e9b0310e
7
+ data.tar.gz: b44bd4309088740adcc2047216ffe49ced4528f2004107be4e93f39d9cb20c19202dc54846433268f575b3222354f611cf235dc16f54d7edc720e25df1b1719f
@@ -0,0 +1,30 @@
1
+ version: 2
2
+
3
+ jobs:
4
+ build: &build
5
+ docker:
6
+ - image: circleci/ruby:latest
7
+ steps:
8
+ - checkout
9
+ - run:
10
+ name: Install gems
11
+ command: bundle install
12
+ - run:
13
+ name: RSpec
14
+ command: rspec
15
+ ruby-2.4:
16
+ <<: *build
17
+ docker:
18
+ - image: circleci/ruby:2.4
19
+
20
+ ruby-2.5:
21
+ <<: *build
22
+ docker:
23
+ - image: circleci/ruby:2.5
24
+
25
+ workflows:
26
+ version: 2
27
+ build-multiple-rubies:
28
+ jobs:
29
+ - ruby-2.4
30
+ - ruby-2.5
@@ -4,40 +4,55 @@ require 'active_support/core_ext/hash'
4
4
  module Moromi
5
5
  module Apns
6
6
  class Parameter
7
+ PUSH_TYPE_ALERT = 1
8
+ PUSH_TYPE_BACKGROUND = 2
9
+
7
10
  attr_reader :alert
8
11
  attr_reader :badge
9
12
  attr_reader :sound
10
- attr_reader :content_available
11
13
  attr_reader :mutable_content
12
14
  attr_reader :category
13
15
  attr_reader :priority
14
16
  attr_reader :custom_data
15
17
 
16
- def initialize(alert:, badge:, sound: 'default', content_available: 1, mutable_content: 0, category: nil, priority: 10, custom_data: {})
18
+ def initialize(alert:, badge:, sound: 'default', push_type: PUSH_TYPE_ALERT, mutable_content: 0, category: nil, priority: 10, custom_data: {}, **options)
17
19
  @alert = alert
18
20
  @badge = badge
19
21
  @sound = sound
20
- @content_available = content_available
22
+ @push_type = normalize_push_type(push_type)
21
23
  @mutable_content = mutable_content
22
24
  @category = category
23
25
  @priority = priority
24
26
  @custom_data = custom_data
27
+ @options = options
25
28
  end
26
29
 
27
30
  def self.make_silent_push_parameter(priority: 10, custom_data: {})
28
- new(alert: '', badge: nil, sound: nil, content_available: 1, priority: priority, custom_data: custom_data)
31
+ new(alert: '', badge: nil, sound: nil, push_type: PUSH_TYPE_BACKGROUND, priority: priority, custom_data: custom_data)
29
32
  end
30
33
 
31
34
  def ==(other)
32
35
  serialize == other.serialize
33
36
  end
34
37
 
38
+ # https://docs.aws.amazon.com/ja_jp/sns/latest/dg/sns-send-custom-platform-specific-payloads-mobile-devices.html#mobile-push-send-message-apns-background-notification
39
+ def content_available
40
+ case @push_type
41
+ when PUSH_TYPE_ALERT
42
+ 'alert'
43
+ when PUSH_TYPE_BACKGROUND
44
+ 1
45
+ else
46
+ 'alert'
47
+ end
48
+ end
49
+
35
50
  def serialize
36
51
  {
37
52
  alert: @alert,
38
53
  badge: @badge,
39
54
  sound: @sound,
40
- content_available: @content_available,
55
+ push_type: @push_type,
41
56
  mutable_content: @mutable_content,
42
57
  category: @category,
43
58
  priority: @priority,
@@ -51,13 +66,26 @@ module Moromi
51
66
  alert: hash[:alert],
52
67
  badge: hash[:badge],
53
68
  sound: hash[:sound],
54
- content_available: hash[:content_available],
69
+ push_type: hash[:push_type],
55
70
  mutable_content: hash[:mutable_content],
56
71
  category: hash[:category],
57
72
  priority: hash[:priority],
58
73
  custom_data: hash[:custom_data]
59
74
  )
60
75
  end
76
+
77
+ private
78
+
79
+ def normalize_push_type(value)
80
+ case value
81
+ when PUSH_TYPE_ALERT
82
+ PUSH_TYPE_ALERT
83
+ when PUSH_TYPE_BACKGROUND
84
+ PUSH_TYPE_BACKGROUND
85
+ else
86
+ PUSH_TYPE_ALERT
87
+ end
88
+ end
61
89
  end
62
90
  end
63
91
  end
@@ -1,5 +1,5 @@
1
1
  module Moromi
2
2
  module Apns
3
- VERSION = '0.9.0'
3
+ VERSION = '0.10.0'
4
4
  end
5
5
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency 'activesupport', ['>= 4.2']
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.12"
26
+ spec.add_development_dependency "bundler"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moromi-apns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Ooishi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-01 00:00:00.000000000 Z
11
+ date: 2019-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.12'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.12'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".circleci/config.yml"
76
77
  - ".gitignore"
77
78
  - ".rspec"
78
79
  - Gemfile
@@ -81,7 +82,6 @@ files:
81
82
  - Rakefile
82
83
  - bin/console
83
84
  - bin/setup
84
- - circle.yml
85
85
  - lib/moromi-apns.rb
86
86
  - lib/moromi/apns.rb
87
87
  - lib/moromi/apns/config.rb
@@ -119,8 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.6.13
122
+ rubygems_version: 3.0.3
124
123
  signing_key:
125
124
  specification_version: 4
126
125
  summary: APNS model
data/circle.yml DELETED
@@ -1,4 +0,0 @@
1
- machine:
2
- ruby:
3
- version:
4
- 2.3.1