houston 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/README.md +30 -3
- data/bin/apn +0 -0
- data/houston-0.1.0.gem +0 -0
- data/lib/houston.rb +1 -1
- data/lib/houston/client.rb +4 -1
- data/lib/houston/notification.rb +2 -1
- metadata +33 -13
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
houston (0.1.
|
4
|
+
houston (0.1.1)
|
5
5
|
commander (~> 4.1.2)
|
6
6
|
json (~> 1.7.3)
|
7
7
|
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
commander (4.1.2)
|
12
12
|
highline (~> 1.6.11)
|
13
|
-
highline (1.6.
|
13
|
+
highline (1.6.15)
|
14
14
|
json (1.7.5)
|
15
15
|
rake (0.9.2.2)
|
16
16
|
rspec (0.6.4)
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ In a production application, you will probably want to schedule or queue notific
|
|
11
11
|
|
12
12
|
Another caveat is that Houston doesn't manage device tokens for you. Infrastructures can vary dramatically for these kinds of things, so being agnostic and not forcing any conventions here is more a feature than a bug, perhaps. Treat it the same way as you would an e-mail address, associating one or many for each user account.
|
13
13
|
|
14
|
-
_That said, a simple web service adapter, similar to [Rack::CoreData](https://github.com/mattt/rack-core-data)
|
14
|
+
_That said, a simple web service adapter, similar to [Rack::CoreData](https://github.com/mattt/rack-core-data) is in the cards._
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
@@ -22,8 +22,9 @@ $ gem install houston
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
# Environment variables are automatically read, or can be overridden by any specified options
|
26
|
-
|
25
|
+
# Environment variables are automatically read, or can be overridden by any specified options. You can also
|
26
|
+
# conveniently use `Houston::Client.development` or `Houston::Client.production`.
|
27
|
+
APN = Houston::Client.development
|
27
28
|
APN.certificate = File.read("/path/to/apple_push_notification.pem")
|
28
29
|
|
29
30
|
# An example of the token sent back when a device registers for notifications
|
@@ -50,6 +51,32 @@ Houston also comes with the `apn` binary, which provides a convenient way to tes
|
|
50
51
|
$ apn push "<token>" -c /path/to/apple_push_notification.pem -m "Hello from the command line!"
|
51
52
|
```
|
52
53
|
|
54
|
+
## Enabling Push Notifications on iOS
|
55
|
+
|
56
|
+
### AppDelegate.m
|
57
|
+
|
58
|
+
```objective-c
|
59
|
+
- (void)applicationDidFinishLaunching:(UIApplication *)application {
|
60
|
+
// ...
|
61
|
+
|
62
|
+
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
|
63
|
+
}
|
64
|
+
|
65
|
+
- (void)application:(UIApplication *)application
|
66
|
+
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
67
|
+
{
|
68
|
+
NSLog(@"application:didRegisterForRemoteNotificationsWithDeviceToken: %@", deviceToken);
|
69
|
+
|
70
|
+
// Register the device token with a webservice
|
71
|
+
}
|
72
|
+
|
73
|
+
- (void)application:(UIApplication *)application
|
74
|
+
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
75
|
+
{
|
76
|
+
NSLog(@"Error: %@", error);
|
77
|
+
}
|
78
|
+
```
|
79
|
+
|
53
80
|
## Converting Your Certificate
|
54
81
|
|
55
82
|
> These instructions come from the [APN on Rails](https://github.com/PRX/apn_on_rails) project, which is another great option for sending push notifications.
|
data/bin/apn
CHANGED
File without changes
|
data/houston-0.1.0.gem
CHANGED
Binary file
|
data/lib/houston.rb
CHANGED
data/lib/houston/client.rb
CHANGED
@@ -30,8 +30,11 @@ module Houston
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def push(*notifications)
|
33
|
+
return if notifications.empty?
|
34
|
+
|
33
35
|
Connection.open(connection_options_for_endpoint(:gateway)) do |connection, socket|
|
34
|
-
notifications.each do |notification|
|
36
|
+
notifications.flatten.each do |notification|
|
37
|
+
next unless notification.kind_of?(Notification)
|
35
38
|
next if notification.sent?
|
36
39
|
|
37
40
|
connection.write(notification.message)
|
data/lib/houston/notification.rb
CHANGED
@@ -26,8 +26,9 @@ module Houston
|
|
26
26
|
|
27
27
|
def message
|
28
28
|
json = payload.to_json
|
29
|
+
device_token = [@device.gsub(/[<\s>]/, '')].pack('H*')
|
29
30
|
|
30
|
-
|
31
|
+
[0, 0, 32, device_token, 0, json.bytes.count, json].pack('ccca*cca*')
|
31
32
|
end
|
32
33
|
|
33
34
|
def mark_as_sent!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: houston
|
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:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: commander
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 4.1.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 4.1.2
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: json
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 1.7.3
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.7.3
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 0.6.1
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.6.1
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rake
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,7 +69,12 @@ dependencies:
|
|
54
69
|
version: 0.9.2
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.9.2
|
58
78
|
description: Houston is a simple gem for sending Apple Push Notifications. Pass your
|
59
79
|
credentials, construct your message, and send it.
|
60
80
|
email: m@mattt.me
|
@@ -90,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
110
|
version: '0'
|
91
111
|
segments:
|
92
112
|
- 0
|
93
|
-
hash:
|
113
|
+
hash: -1059375513586504727
|
94
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
115
|
none: false
|
96
116
|
requirements:
|
@@ -99,10 +119,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
119
|
version: '0'
|
100
120
|
segments:
|
101
121
|
- 0
|
102
|
-
hash:
|
122
|
+
hash: -1059375513586504727
|
103
123
|
requirements: []
|
104
124
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.8.
|
125
|
+
rubygems_version: 1.8.24
|
106
126
|
signing_key:
|
107
127
|
specification_version: 3
|
108
128
|
summary: Send Apple Push Notifications
|