notifiable-gcm-spacialdb 0.4.2 → 0.4.3
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 +18 -14
- data/lib/notifiable/gcm/spacialdb/version.rb +1 -1
- data/spec/batch_spec.rb +8 -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: 39da622a652408c9b14236037e7c5f3277b47ccb
|
4
|
+
data.tar.gz: 4b077b4d0e543dfbea5d478619bb6d9ea2eaa471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 887884ce3c312cb2b85f7fbf0a81101f1bee97c6884d47947d2d764e259c9a3c15013a4df2315e2f9ff01c7f61be108f1c9264fd2b5ae78d09ac29a0eb4d77a4
|
7
|
+
data.tar.gz: 3882e1069905b53f58541148a5094a35d52969d0438c87478397f0cf19b3f2b4f1aafd282a4260451408ebb12d38aa551898e24f54a0d95b8a9cfc4a3b1204e2
|
data/Gemfile.lock
CHANGED
@@ -45,22 +45,26 @@ module Notifiable
|
|
45
45
|
|
46
46
|
# send
|
47
47
|
response = gcm.send_notification(device_tokens.collect{|dt| dt.token}, {:data => data})
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
if response[:status_code] == 200
|
49
|
+
body = JSON.parse(response.fetch(:body, "{}"))
|
50
|
+
results = body.fetch("results", [])
|
51
|
+
results.each_with_index do |result, idx|
|
52
|
+
# Remove the token if it is marked NotRegistered (user deleted the App for example)
|
53
|
+
if ["InvalidRegistration", "NotRegistered"].include? result["error"]
|
54
|
+
device_tokens[idx].update_attribute('is_valid', false)
|
55
|
+
else
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
# Update the token if a canonical ID is returned
|
58
|
+
if result["registration_id"]
|
59
|
+
device_tokens[idx].update_attribute('token', result["registration_id"])
|
60
|
+
end
|
61
|
+
end
|
61
62
|
|
62
|
-
|
63
|
-
|
63
|
+
processed(notification, device_tokens[idx], error_code(result["error"]))
|
64
|
+
end
|
65
|
+
else
|
66
|
+
Rails.logger.error "Sending notification id: #{notification.id} code: #{response[:status_code]} response: #{response[:response]}"
|
67
|
+
end
|
64
68
|
end
|
65
69
|
self.batch.delete(notification.id)
|
66
70
|
end
|
data/spec/batch_spec.rb
CHANGED
@@ -70,6 +70,14 @@ describe Notifiable::Gcm::Spacialdb::Batch do
|
|
70
70
|
d.token.should eql "GHJ12345"
|
71
71
|
end
|
72
72
|
|
73
|
+
it "deals gracefully with an unauthenticated key" do
|
74
|
+
stub_request(:post, "https://android.googleapis.com/gcm/send").to_return(:body => '<html>Message</html>', :status => 401)
|
75
|
+
|
76
|
+
Notifiable.batch {|b| b.add(n, u)}
|
77
|
+
|
78
|
+
Notifiable::NotificationStatus.count.should == 0
|
79
|
+
end
|
80
|
+
|
73
81
|
end
|
74
82
|
|
75
83
|
User = Struct.new(:device_token) do
|
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.4.
|
4
|
+
version: 0.4.3
|
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-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: notifiable-rails
|