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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04756d3defad1dec265ce5819d159988225880ff
4
- data.tar.gz: 9dcb2cec3d06541393da88d510e9af9402d44e4e
3
+ metadata.gz: f9784309763be4372a1a8fcce73a191c081714dd
4
+ data.tar.gz: 44a1546f4f812e679cf5dd07ca00e1860737a5ad
5
5
  SHA512:
6
- metadata.gz: 7e74f84c2f1079d9e9c29dc54add173d64bbcec34c73990005595c662fe1e4e4f727a6d40d4fb75766c1d764c1aafcfd434dfe8b0135af974f86c169f02ffba7
7
- data.tar.gz: 5d5bdc88e83331da34bc2bcab63b1f6e73c2f2776f6b26c3850fa9ab708fe5dbf2908221c31ed9aafca2552b3ed0f974b9b300fcbf3e23d5c6fb34c8ef0dda28
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
- Pushofy::ApplePush.new('gateway.sandbox.push.apple.com',2195,payload_hash, device_token_hex,'/Users/apple/Documents/workspace/pushofy/DevCert.pem',"akk322").push
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
- a = Pushofy::AndroidPush.new(body,"AIzaSyCoTPiIlC9OKuLh6i66focOp3zygWWOKXs")
89
+ settings = {
90
+ api_key: "AIzaSyCoTPiIlC9OKuLh6i66focOp3zygWWOKXs"
91
+ }
92
+ a = Pushofy::AndroidPush.new(body,settings)
85
93
  a.push
@@ -5,13 +5,13 @@ require 'uri'
5
5
  #
6
6
  module Pushofy
7
7
  class AndroidPush
8
- def initialize(body,api_key)
9
- @api_key = api_key
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)
@@ -6,17 +6,14 @@ require 'openssl'
6
6
  #
7
7
  module Pushofy
8
8
  class ApplePush
9
- def initialize(host,port,payload_hash, deviceTokenHex,cert_name,password)
10
- @payload_hash = payload_hash
11
- @deviceTokenHex = deviceTokenHex
12
- @cert_name = cert_name
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,@port, @password,@cert_name)
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*')
@@ -1,3 +1,3 @@
1
1
  module Pushofy
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
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.15
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-03 00:00:00.000000000 Z
11
+ date: 2014-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler