bpoweski-apnserver 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/apnserver.gemspec +3 -4
- data/bin/apnsend +74 -4
- metadata +4 -5
- data/bin/apns +0 -11
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/apnserver.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{apnserver}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben Poweski"]
|
12
|
-
s.date = %q{2009-09-
|
12
|
+
s.date = %q{2009-09-15}
|
13
13
|
s.description = %q{A toolkit for proxying and sending Apple Push Notifications}
|
14
14
|
s.email = %q{bpoweski@3factors.com}
|
15
|
-
s.executables = ["
|
15
|
+
s.executables = ["apnsend", "apnserverd"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"README.rdoc"
|
18
18
|
]
|
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
|
|
23
23
|
"Rakefile",
|
24
24
|
"VERSION",
|
25
25
|
"apnserver.gemspec",
|
26
|
-
"bin/apns",
|
27
26
|
"bin/apnsend",
|
28
27
|
"bin/apnserverd",
|
29
28
|
"lib/apnserver.rb",
|
data/bin/apnsend
CHANGED
@@ -5,9 +5,79 @@ require 'getoptlong'
|
|
5
5
|
require 'rubygems'
|
6
6
|
require 'apnserver'
|
7
7
|
require 'base64'
|
8
|
+
require 'socket'
|
9
|
+
|
10
|
+
def usage
|
11
|
+
puts "Usage: apnsend [switches] (--b64-token | --hex-token) <token>"
|
12
|
+
puts " --server <localhost> the apn server defaults to a locally running apnserverd"
|
13
|
+
puts " --port <2195> the port of the apn server"
|
14
|
+
puts " --pem <path> the path to the pem file, if a pem is supplied the server defaults to gateway.push.apple.com:2195"
|
15
|
+
puts " --alert <message> the message to send"
|
16
|
+
puts " --sound <default> the sound to play, defaults to 'default'"
|
17
|
+
puts " --badge <number> the badge number"
|
18
|
+
puts " --custom <json string> a custom json string to be added to the main object"
|
19
|
+
puts " --b64-token <token> a base 64 encoded device token"
|
20
|
+
puts " --hex-token <token> a hex encoded device token"
|
21
|
+
puts " --help this message"
|
22
|
+
end
|
23
|
+
|
24
|
+
opts = GetoptLong.new(
|
25
|
+
["--server", "-s", GetoptLong::REQUIRED_ARGUMENT],
|
26
|
+
["--port", "-p", GetoptLong::REQUIRED_ARGUMENT],
|
27
|
+
["--pem", "-c", GetoptLong::REQUIRED_ARGUMENT],
|
28
|
+
["--alert", "-a", GetoptLong::REQUIRED_ARGUMENT],
|
29
|
+
["--sound", "-S", GetoptLong::REQUIRED_ARGUMENT],
|
30
|
+
["--badge", "-b", GetoptLong::REQUIRED_ARGUMENT],
|
31
|
+
["--custom", "-j", GetoptLong::REQUIRED_ARGUMENT],
|
32
|
+
["--b64-token", "-B", GetoptLong::REQUIRED_ARGUMENT],
|
33
|
+
["--hex-token", "-H", GetoptLong::REQUIRED_ARGUMENT],
|
34
|
+
["--help", "-h", GetoptLong::NO_ARGUMENT]
|
35
|
+
)
|
36
|
+
|
37
|
+
port = nil
|
38
|
+
server = nil
|
39
|
+
notification = ApnServer::Notification.new
|
40
|
+
token = nil
|
41
|
+
pem = nil
|
42
|
+
|
43
|
+
opts.each do |opt, arg|
|
44
|
+
case opt
|
45
|
+
when '--help'
|
46
|
+
usage
|
47
|
+
exit
|
48
|
+
when '--server'
|
49
|
+
server = arg
|
50
|
+
when '--port'
|
51
|
+
port = arg
|
52
|
+
when '--pem'
|
53
|
+
pem = arg
|
54
|
+
when '--alert'
|
55
|
+
notification.alert = arg
|
56
|
+
when '--sound'
|
57
|
+
notification.sound = arg
|
58
|
+
when '--badge'
|
59
|
+
notification.badge = arg
|
60
|
+
when '--custom'
|
61
|
+
notification.custom = arg
|
62
|
+
when '--b64-token'
|
63
|
+
token = Base64::decode64(arg)
|
64
|
+
when '--hex-token'
|
65
|
+
token = arg.unpack('H*')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
if token.nil?
|
71
|
+
usage
|
72
|
+
exit
|
73
|
+
end
|
74
|
+
|
75
|
+
if pem.nil?
|
76
|
+
@client = TCPSocket.new(server || 'localhost', port || 22195)
|
77
|
+
else
|
78
|
+
@client = ApnServer::Client.new(pem, server || 'gateway.push.apple.com', port || 2195)
|
79
|
+
end
|
80
|
+
|
81
|
+
@client.write(notification.to_bytes)
|
8
82
|
|
9
|
-
client = ApnServer::Client.new(ARGV.first)
|
10
|
-
client.connect!
|
11
83
|
|
12
|
-
token = Base64.decode64(ARGV.last)
|
13
|
-
client.write("\0\0 #{token}\0#{22.chr}{\"aps\":{\"alert\":\"Hi\"}}")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bpoweski-apnserver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Poweski
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-15 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -35,7 +35,6 @@ dependencies:
|
|
35
35
|
description: A toolkit for proxying and sending Apple Push Notifications
|
36
36
|
email: bpoweski@3factors.com
|
37
37
|
executables:
|
38
|
-
- apns
|
39
38
|
- apnsend
|
40
39
|
- apnserverd
|
41
40
|
extensions: []
|
@@ -49,7 +48,6 @@ files:
|
|
49
48
|
- Rakefile
|
50
49
|
- VERSION
|
51
50
|
- apnserver.gemspec
|
52
|
-
- bin/apns
|
53
51
|
- bin/apnsend
|
54
52
|
- bin/apnserverd
|
55
53
|
- lib/apnserver.rb
|
@@ -66,6 +64,7 @@ files:
|
|
66
64
|
- test/test_protocol.rb
|
67
65
|
has_rdoc: false
|
68
66
|
homepage: http://github.com/bpoweski/apnserver
|
67
|
+
licenses:
|
69
68
|
post_install_message:
|
70
69
|
rdoc_options:
|
71
70
|
- --charset=UTF-8
|
@@ -86,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
85
|
requirements: []
|
87
86
|
|
88
87
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.3.5
|
90
89
|
signing_key:
|
91
90
|
specification_version: 3
|
92
91
|
summary: Apple Push Notification Server
|
data/bin/apns
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
|
4
|
-
require 'socket'
|
5
|
-
require 'base64'
|
6
|
-
require 'rubygems'
|
7
|
-
|
8
|
-
socket = TCPSocket.new('localhost', 22195)
|
9
|
-
token = Base64.decode64(ARGV.last)
|
10
|
-
socket.write("\0\0 #{token}\0#{22.chr}{\"aps\":{\"alert\":\"Hi\"}}")
|
11
|
-
socket.close
|