notifiable-gcm-spacialdb 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: 71437054a180ba21f1597725988dbb8f73fdb025
4
- data.tar.gz: a218b16c1040f97b82de352b780e7d4516ee3127
3
+ metadata.gz: 72fa2263055bf8dd620b8ee6cd8b8473591903ee
4
+ data.tar.gz: a6e243b56b821c45e7fe30e3a6535e60d88109b2
5
5
  SHA512:
6
- metadata.gz: ca513966699805ffdd5bbefc0fe97db092dd768e1a3cb94544731a2b0a721cb80f5db4da84a7a9268cec52ff02672ddef8d576feb80aca30e78baddae4b72485
7
- data.tar.gz: 4c1ff8de8a399758fb47a15db8743ff41a9fb39ee083ced9e26a74c8e8ce74dcb9ed741936d8680abbeee576a0597afe91efcca2ff19ea27dc2b9d7635625c11
6
+ metadata.gz: dc69093dbe4345789f462898f5bab11cd40b89305b5b1dc779a61eef3df5265e6c2dc595f5d18940eeab98cdc35552b33d92c062cdd6605d99ade93f761fd336
7
+ data.tar.gz: 7a7ba55186825dce8fd48e953606e12d09a8a38a50d2fb03edf041a4b611ea10e53e1b911f4c3b0dc1091f5197594e1d239e2a785486de89960d461297cfbf44
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- notifiable-gcm-spacialdb (0.2.0)
4
+ notifiable-gcm-spacialdb (0.2.1)
5
5
  gcm (~> 0.0.6)
6
6
  notifiable-rails (>= 0.4.0)
7
7
 
@@ -40,9 +40,18 @@ module Notifiable
40
40
  else
41
41
  gcm = ::GCM.new(self.api_key)
42
42
 
43
+ data = {}
44
+
45
+ # message
43
46
  message = notification.provider_value(device_tokens.first.provider, :message)
47
+ data[:message] = message if message
48
+
49
+ # custom attributes
50
+ custom_attributes = notification.provider_value(device_tokens.first.provider, :data)
51
+ data.merge! custom_attributes if custom_attributes
44
52
 
45
- response = gcm.send_notification(device_tokens.collect{|dt| dt.token}, {:data => {:message => message}})
53
+ # send
54
+ response = gcm.send_notification(device_tokens.collect{|dt| dt.token}, {:data => data})
46
55
  body = JSON.parse(response.fetch(:body, "{}"))
47
56
  results = body.fetch("results", [])
48
57
  results.each_with_index do |result, idx|
@@ -1,7 +1,7 @@
1
1
  module Notifiable
2
2
  module Gcm
3
3
  module Spacialdb
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
6
6
  end
7
7
  end
@@ -16,6 +16,19 @@ describe Notifiable::Gcm::Spacialdb::Batch do
16
16
  Notifiable::NotificationDeviceToken.count.should == 1
17
17
  end
18
18
 
19
+ it "sends custom attributes" do
20
+ n.update_attribute(:payload, {:gcm => {:data => {:custom_id => 123456}}})
21
+
22
+ stub_request(:post, "https://android.googleapis.com/gcm/send")
23
+ .with(:body => {:registration_ids => ["ABC123"], :data => {:message => n.message, :custom_id => 123456}})
24
+ .to_return(:body => '{ "multicast_id": 108, "success": 1, "failure": 0, "canonical_ids": 0, "results": [{ "message_id": "1:08" }]}')
25
+
26
+ g.send_notification(n, d)
27
+ g.close
28
+
29
+ Notifiable::NotificationDeviceToken.count.should == 1
30
+ end
31
+
19
32
  it "sends a single gcm notification in a batch" do
20
33
  stub_request(:post, "https://android.googleapis.com/gcm/send").to_return(:body => '{ "multicast_id": 108, "success": 1, "failure": 0, "canonical_ids": 0, "results": [{ "message_id": "1:08" }]}')
21
34
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifiable-gcm-spacialdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kamil Kocemba
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-09 00:00:00.000000000 Z
12
+ date: 2014-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: notifiable-rails