pushofy 0.0.20 → 0.0.21

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0e8a10dce7873bbd7d804060dd0a2b9ec31b5d2
4
- data.tar.gz: ca604e7b22c09bb888df75fbd57b6d25f61510ca
3
+ metadata.gz: 4a84db1ba394a0ad2062cab8812a05971c4a7f18
4
+ data.tar.gz: 8b3471d5e69459c35cf4c2bab20981b8b7554bd1
5
5
  SHA512:
6
- metadata.gz: 5f41299b9121057b080a634662c1b48f08c806d6cae126a0f5448b2eeecd82efbb9a1d36254be7f8953649c9cfdc13c6f8468467b793432a2c036f731df421f1
7
- data.tar.gz: 6552788ea038652ccfa771beed2666718eece21a9f3599ebfc4a4ec75ad95baeff272e1d428f8369ad72269cde7cb8d70eed351773db82c15422715a2484bbd3
6
+ metadata.gz: 9b21bd61079fa1d05c07ba287d3c2c95f5f225208bcc33f2b13dcc4f86b12711db415b99355b156cc405a1fc4d5b32c20109ae0fd65f98ac440aff600d1b7969
7
+ data.tar.gz: c714af6c0ba1fe609d7a81b875d1f6b76b608c5805427421e737ee0cde2e59e47ae120594e0a761362234852151b21b9b9696a0ddf35e2ecb805509009ec8ffd
@@ -1,4 +1,64 @@
1
+ require 'rubygems'
2
+ require 'socket'
3
+ require_relative 'applepayload'
4
+ require_relative 'ssl_helper'
5
+ require 'openssl'
1
6
  module Pushofy
2
7
  class Payload
8
+ def initialize(args = {})
9
+ @id = args[:id]
10
+ @message = args[:message]
11
+ @app = args[:app]
12
+ @from = args[:from]
13
+ end
14
+
15
+
16
+
17
+ def send_push
18
+ device = Device.find(@id)
19
+ device_type = device.device_type
20
+ if device_type == 'IOS'
21
+ send_to_ios(device)
22
+ elsif device_type == 'Android'
23
+ send_to_android(device)
24
+ end
25
+ end
26
+
27
+ def send_to_ios(device)
28
+
29
+
30
+ payload_hash = {
31
+ aps: {
32
+ alert: {
33
+ body: "You have a new #{@app}, form #{@from}"
34
+ },
35
+ sound: 'default',
36
+ badge: 1,
37
+ },
38
+ app: @app,
39
+ url: @message
40
+ }
41
+
42
+ ApplePush.new(payload_hash, device_token_hex).push
43
+ end
44
+
45
+ def send_to_android(device)
46
+ body = {}
47
+ arr = []
48
+ arr << device.registration_id
49
+ body['registration_ids'] = arr
50
+ # body['collapse_key'] = 'Updates Available'
51
+ # body['registration_ids'] = registration_ids
52
+ # body['data'] = 'Hi this is my first push message'
53
+ # body['delay_while_idle'] = # true or false
54
+ # body['time_to_live'] = # number in seconds
55
+ android_payload = { 'message' => "You have a new #{app} from #{from}" }
56
+ android_payload['app'] = @app
57
+ android_payload['url'] = @message
58
+ body['data'] = android_payload
59
+ a = AndroidPush.new
60
+ a.push(body)
61
+ end
3
62
  end
63
+
4
64
  end
@@ -1,3 +1,3 @@
1
1
  module Pushofy
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.21"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushofy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ankur Kothari