hey-you-fcm-push 0.1.2 → 0.2.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
2
  SHA256:
3
- metadata.gz: 5106b508a9c987afbfb4597e104b975ce8cda559d255beb39955302352e76fa8
4
- data.tar.gz: '085dc0e137957caa88c8e1678321b6f4307f6e7a4f3c07737764c7b496edd8d0'
3
+ metadata.gz: 8c286e9339b6ef0cc781b92c78cb47bd1850cedf08dc210798cead1d711d1002
4
+ data.tar.gz: 19e09925db997861cbf98f374fd1edb6bcbbdab5f26e981bfa87d6e57adc6649
5
5
  SHA512:
6
- metadata.gz: 0dab0074971c66c4b6b69778e5f6488b34481ebbfb7b98099cc7fc4af77e91fa7a6dc9f42103d5896d7b92efca67ad0e4d9edafa5ee12fc84ad49cadcf119ed1
7
- data.tar.gz: 1bdc0ecddf136907f145334ce58095dac3134ef486472e4ae55c34af26fdf44d830c613abf2c9e24ef2218266b6e517f2b8a7e9002488fb497e7e7018ddaa857
6
+ metadata.gz: d0af3921010cbce6a05c327bdeaf61646c039c97a022bc39cf00ac2bfd4935eb9743bc425d3afb4be9c35cca3bafe5f3fe2aaa374c55ef5473764114d409c135
7
+ data.tar.gz: b7e5220ee1e99beaf54f3f90367bf634abf6ba134a7ec2b00c1c224aace2adec8abf6aa60c53a9a4e3f3243cc2f572214c22a3ecf05b5da3c23b6a1ff6f3cc6a
@@ -10,6 +10,7 @@ module HeyYou
10
10
  # @param [HeyYou::Builder] builder - builder with notifications texts and settings
11
11
  # @option [String] name - Output Only. The identifier of the message sent
12
12
  # @option [String] token - Registration token to send a message to.
13
+ # @option [String] to - Alias for `token`. `token` in high priority.
13
14
  # @option [String] topic - Topic name to send a message to, e.g. "weather".
14
15
  # @option [String] condition - Condition to send a message to, e.g. "'foo' in topics && 'bar' in topics".
15
16
  # @option [Hash] notification - Basic notification template to use across all platforms.
@@ -19,12 +20,21 @@ module HeyYou
19
20
  # @option [Hash] fcm_options - Platform independent options for features provided by the FCM SDKs.
20
21
  # @option [Hash] push_data - Input only. Arbitrary key/value payload. The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm").
21
22
  #
22
- # @return [Hash] - FCM response
23
+ # @return [Array{Hash}] - FCM responses
23
24
  #
24
25
  # @see: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#resource:-message
25
26
  def send!(builder, **options)
26
- message = build_message(builder, **options)
27
- HeyYouFcmPush::Connection.instance.send_notification(message, validate_only: options[:validate_only])
27
+ options[:token] ||= options[:to]
28
+
29
+ if options[:token].is_a?(Array)
30
+ messages = options[:token].map { |token| build_message(builder, **options.merge(token: token)) }
31
+ end
32
+
33
+ messages ||= [build_message(builder, **options)]
34
+
35
+ messages.map do |message|
36
+ HeyYouFcmPush::Connection.instance.send_notification(message, validate_only: options[:validate_only])
37
+ end
28
38
  end
29
39
 
30
40
  private
@@ -1,3 +1,3 @@
1
1
  module HeyYouFcmPush
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hey-you-fcm-push
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Nesterov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-26 00:00:00.000000000 Z
11
+ date: 2021-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hey-you