speedy_c2dm 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.markdown CHANGED
@@ -6,7 +6,7 @@ c2dm sends push notifications to Android devices via google [c2dm](http://code.g
6
6
 
7
7
  To use C2DM the server needs to fetch and store authenticaion tokens from Google. This token will periodically expire, and the recommendation from Google is that "the server should store the token and have a policy to refresh it periodically." Other C2DM gems take a brute force method around this issue, by requesting a new authenticaion token from Google for *each* notification request they send. This effectively doubles the number of HTTP calls being made for each notification.
8
8
 
9
- This GEM will request the token when the SpeedyC2DM::API class is first initialized. From then on, it will use the auth token stored as an instance variable. On subsequent notification calls, it will check for 'Update-Client-Auth' or check for status 401 (auth failed). When it detects either of these, it will then request new tokens from Google servers. In the case of status 503 (service unavailable), a return message indicating 503 is returned. It is suggested that you retry after exponential back-off in the case of 503 (using something like resque-retry).
9
+ This GEM will request the token when the SpeedyC2DM::API class is first initialized. From then on, calls to SpeedyC2DM::API.send_notification() will use the auth token stored in the class instance variable. On subsequent notification calls, the object will check for 'Update-Client-Auth' or check for status 401 (auth failed). If it detects either of these, it will immediately request new tokens from Google servers. In the case of status 503 (service unavailable), a return message indicating 503 is returned. It is suggested that you retry after exponential back-off in the case of 503 (using something like [resque-retry](https://github.com/lantins/resque-retry)).
10
10
 
11
11
  ##Installation
12
12
 
@@ -29,6 +29,19 @@ options = {
29
29
 
30
30
  response = c2dm.send_notification(options)
31
31
 
32
+ Note: there are blocking calls in both .new() and .send_notification(). You should use an async queue like Resque to ensure non-blocking behavior in your application code.
33
+
34
+
35
+ ##Testing
36
+
37
+ to test, first fill out these variables in test/test_speedy_c2dm.rb:
38
+ TEST_EMAIL = "TODO - Fill me"
39
+ TEST_PASSWORD = "TODO - Fill me"
40
+ TEST_REGISTRATION_ID = "TODO - Fill me"
41
+
42
+ then run:
43
+ $ ruby test/test_speedy_c2dm.rb
44
+
32
45
  ##Copyrights
33
46
 
34
47
  * See LICENSE.txt for details.
@@ -1,3 +1,3 @@
1
1
  module SpeedyC2dm
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/speedy_c2dm.rb CHANGED
@@ -58,13 +58,12 @@ module SpeedyC2DM
58
58
  # see more documentation here: http://code.google.com/android/c2dm/#testing
59
59
  if response.code.eql? 200
60
60
 
61
- # look for the header 'Update-Client-Auth'
62
- # in the response you get after sending a message. It indicates that
63
- # this is the token to be used for the next message to send.
61
+ # look for the header 'Update-Client-Auth' in the response you get after sending
62
+ # a message. It indicates that this is the token to be used for the next message to send.
64
63
  if response.headers_hash['Update-Client-Auth']
65
- @auth_token = get_auth_token(@email, @password)
64
+ @auth_token = response.headers_hash['Update-Client-Auth']
66
65
  end
67
- return "success: 200"
66
+ return response.inspect
68
67
 
69
68
  elsif response.code.eql? 401
70
69
 
@@ -74,18 +73,12 @@ module SpeedyC2DM
74
73
  hydra.run # this is a blocking call that returns once all requests are complete
75
74
 
76
75
  response_inner = request.response
77
- if response_inner.code.eql? 200
78
- return "success"
79
- elsif response_inner.code.eql? 401
80
- return "failed: 401 - auth failed"
81
- elsif response_inner.code.eql? 503
82
- return "failed: 503 - service unavailable"
83
- end
76
+ return response.inspect
84
77
 
85
78
  elsif response.code.eql? 503
86
-
79
+
87
80
  # service un-available.
88
- return "failed: 503 - service unavailable"
81
+ return response.inspect
89
82
 
90
83
  end
91
84
  end
data/speedy_c2dm.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = ["sghael@ravidapp.com"]
10
10
  s.homepage = ""
11
11
  s.summary = %q{Speedy C2DM is an intelligent gem for sending push notifications to Android devices via Google C2DM.}
12
- s.description = %q{Speedy C2DM sends push notifications to Android devices via google c2dm.}
12
+ s.description = %q{Speedy C2DM efficiently sends push notifications to Android devices via google c2dm.}
13
13
 
14
14
  s.rubyforge_project = "speedy_c2dm"
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speedy_c2dm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: typhoeus
17
- requirement: &2157328800 !ruby/object:Gem::Requirement
17
+ requirement: &2153057240 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,8 +22,9 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2157328800
26
- description: Speedy C2DM sends push notifications to Android devices via google c2dm.
25
+ version_requirements: *2153057240
26
+ description: Speedy C2DM efficiently sends push notifications to Android devices via
27
+ google c2dm.
27
28
  email:
28
29
  - sghael@ravidapp.com
29
30
  executables: []