pushofy 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/pushofy.rb +12 -4
- data/lib/pushofy/androidpush.rb +3 -3
- data/lib/pushofy/applepush.rb +5 -8
- data/lib/pushofy/version.rb +1 -1
- 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: f9784309763be4372a1a8fcce73a191c081714dd
|
4
|
+
data.tar.gz: 44a1546f4f812e679cf5dd07ca00e1860737a5ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e5502f13e934bdd299e518df09f7506b51bf50ac947447083cd94ce8a693ba924751831061b70bfe8ceb2b170f8f33232f7298bd0b2cbe91ed271f9e850e5b
|
7
|
+
data.tar.gz: 23f598846b7a4d430d69d22f618afc0d750d0dd6d8970885ad9298211918ea1e74f586ed282f51ee8e27e4818cd15ef18ddac3d59740c2956e953238ea8eb44d
|
data/bin/pushofy.rb
CHANGED
@@ -61,10 +61,15 @@ payload_hash['aps']['sound'] = 'default'
|
|
61
61
|
payload_hash['aps']['badge'] = 1
|
62
62
|
payload_hash['app'] = "dsfsdf"
|
63
63
|
payload_hash['url'] = "dsfdfdsf"
|
64
|
-
|
65
|
-
device_token_hex = "A078F1658F68521A278D0F5C41B9C4B0613E4A6DDC157FD8ED1567CDA5634DA4"
|
64
|
+
payload_hash['device'] = "A078F1658F68521A278D0F5C41B9C4B0613E4A6DDC157FD8ED1567CDA5634DA4"
|
66
65
|
# puts payload_hash
|
67
|
-
|
66
|
+
settings = {
|
67
|
+
cert: '/Users/apple/Documents/workspace/pushofy/DevCert.pem',
|
68
|
+
password: "akk322",
|
69
|
+
host: 'gateway.sandbox.push.apple.com',
|
70
|
+
port: 2195
|
71
|
+
}
|
72
|
+
Pushofy::ApplePush.new(payload_hash, settings).push
|
68
73
|
|
69
74
|
# # Things needed
|
70
75
|
# # 1. key
|
@@ -81,5 +86,8 @@ android_payload = { 'message' => "You have a new #{app} from #{from}" }
|
|
81
86
|
android_payload['app'] = app
|
82
87
|
android_payload['url'] = url
|
83
88
|
body['data'] = android_payload
|
84
|
-
|
89
|
+
settings = {
|
90
|
+
api_key: "AIzaSyCoTPiIlC9OKuLh6i66focOp3zygWWOKXs"
|
91
|
+
}
|
92
|
+
a = Pushofy::AndroidPush.new(body,settings)
|
85
93
|
a.push
|
data/lib/pushofy/androidpush.rb
CHANGED
@@ -5,13 +5,13 @@ require 'uri'
|
|
5
5
|
#
|
6
6
|
module Pushofy
|
7
7
|
class AndroidPush
|
8
|
-
def initialize(body,
|
9
|
-
@
|
8
|
+
def initialize(body,settings)
|
9
|
+
@settings = settings
|
10
10
|
@body = body
|
11
11
|
end
|
12
12
|
def push
|
13
13
|
uri = URI('https://android.googleapis.com/gcm/send')
|
14
|
-
auth_key = "key=#{@api_key}"
|
14
|
+
auth_key = "key=#{@settings[:api_key]}"
|
15
15
|
headers = { 'Content-Type' => 'application/json',
|
16
16
|
'Authorization' => auth_key }
|
17
17
|
http = Net::HTTP.new(uri.host, uri.port)
|
data/lib/pushofy/applepush.rb
CHANGED
@@ -6,17 +6,14 @@ require 'openssl'
|
|
6
6
|
#
|
7
7
|
module Pushofy
|
8
8
|
class ApplePush
|
9
|
-
def initialize(
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@password = password
|
14
|
-
@host = host
|
15
|
-
@port = port
|
9
|
+
def initialize(payload_hash, settings)
|
10
|
+
@deviceTokenHex = payload_hash["device"]
|
11
|
+
@payload_hash = payload_hash.delete('device')
|
12
|
+
@settings = settings
|
16
13
|
end
|
17
14
|
def push
|
18
15
|
path = @cert_name
|
19
|
-
ssl_client = Pushofy::ConnectionToAppleServer::ssl_connect(@host
|
16
|
+
ssl_client = Pushofy::ConnectionToAppleServer::ssl_connect(@settings[:host], @settings[:port], @settings[:password], @settings[:cert])
|
20
17
|
ssl_client.connect
|
21
18
|
device = [@deviceTokenHex]
|
22
19
|
device_token_binary = device.pack('H*')
|
data/lib/pushofy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ankur Kothari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|