pushmeup 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -13
- data/lib/pushmeup/gcm/core.rb +11 -2
- data/lib/pushmeup/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -166,24 +166,24 @@ You can use multiple keys to send notifications, to do it just do this changes i
|
|
166
166
|
#### Usage
|
167
167
|
|
168
168
|
# For single notification
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
169
|
+
GCM.send_notification( destination, :identity => :key1 )
|
170
|
+
# Empty notification
|
171
|
+
|
172
|
+
GCM.send_notification( destination, data, :identity => :key1 )
|
173
|
+
# Notification with custom information
|
174
|
+
|
175
|
+
GCM.send_notification( destination, data, :collapse_key => "placar_score_global", :time_to_live => 3600, :delay_while_idle => false, :identity => :key1 )
|
176
|
+
# Notification with custom information and parameters
|
177
|
+
|
178
178
|
# For multiple notifications
|
179
179
|
options1 = {}
|
180
180
|
options2 = {..., :identity => :key2}
|
181
181
|
n1 = GCM::Notification.new(destination1, data1, options1.merge({:identity => :key2}))
|
182
182
|
n2 = GCM::Notification.new(destination2, data2, :identity => :key1)
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
183
|
+
n3 = GCM::Notification.new(destination3, data3, options2)
|
184
|
+
|
185
|
+
GCM.send_notifications( [n1, n2, n3] )
|
186
|
+
# In this case, every notification has his own parameters, options and key
|
187
187
|
|
188
188
|
## Build Status [![Build Status](https://secure.travis-ci.org/NicosKaralis/pushmeup.png?branch=master)](http://travis-ci.org/NicosKaralis/pushmeup) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/NicosKaralis/pushmeup)
|
189
189
|
|
data/lib/pushmeup/gcm/core.rb
CHANGED
@@ -11,6 +11,15 @@ module GCM
|
|
11
11
|
|
12
12
|
class << self
|
13
13
|
attr_accessor :host, :format, :key
|
14
|
+
|
15
|
+
def key(identity = nil)
|
16
|
+
if @key.is_a?(Hash)
|
17
|
+
raise %{If your key is a hash of keys you'l need to pass a identifier to the notification!} if identity.nil?
|
18
|
+
return @key[identity]
|
19
|
+
else
|
20
|
+
return @key
|
21
|
+
end
|
22
|
+
end
|
14
23
|
end
|
15
24
|
|
16
25
|
def self.send_notification(device_tokens, data = {}, options = {})
|
@@ -50,7 +59,7 @@ module GCM
|
|
50
59
|
|
51
60
|
def self.send_push_as_json(n)
|
52
61
|
headers = {
|
53
|
-
'Authorization' => "key=#{ self.key
|
62
|
+
'Authorization' => "key=#{ self.key(n.identity) }",
|
54
63
|
'Content-Type' => 'application/json',
|
55
64
|
}
|
56
65
|
body = {
|
@@ -67,7 +76,7 @@ module GCM
|
|
67
76
|
raise "Still has to be done: http://developer.android.com/guide/google/gcm/gcm.html"
|
68
77
|
headers = {
|
69
78
|
# TODO: Aceitar key ser um hash
|
70
|
-
'Authorization' => "key=#{ self.key
|
79
|
+
'Authorization' => "key=#{ self.key(n.identity) }",
|
71
80
|
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
|
72
81
|
}
|
73
82
|
return self.send_to_server(headers, body)
|
data/lib/pushmeup/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushmeup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -120,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
segments:
|
122
122
|
- 0
|
123
|
-
hash:
|
123
|
+
hash: 3085707259142359060
|
124
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
125
|
none: false
|
126
126
|
requirements:
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
segments:
|
131
131
|
- 0
|
132
|
-
hash:
|
132
|
+
hash: 3085707259142359060
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project: pushmeup
|
135
135
|
rubygems_version: 1.8.24
|