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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/notifiable/gcm/spacialdb/batch.rb +10 -1
- data/lib/notifiable/gcm/spacialdb/version.rb +1 -1
- data/spec/batch_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72fa2263055bf8dd620b8ee6cd8b8473591903ee
|
4
|
+
data.tar.gz: a6e243b56b821c45e7fe30e3a6535e60d88109b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc69093dbe4345789f462898f5bab11cd40b89305b5b1dc779a61eef3df5265e6c2dc595f5d18940eeab98cdc35552b33d92c062cdd6605d99ade93f761fd336
|
7
|
+
data.tar.gz: 7a7ba55186825dce8fd48e953606e12d09a8a38a50d2fb03edf041a4b611ea10e53e1b911f4c3b0dc1091f5197594e1d239e2a785486de89960d461297cfbf44
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
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|
|
data/spec/batch_spec.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: notifiable-rails
|