push_to_sns 0.3.3 → 0.4.0

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: 6bc2d75a5de46a5ae4087652c90eb3870ed15943
4
- data.tar.gz: 0f902d5c2762b01446ecaf4ca935b773b876c7a6
3
+ metadata.gz: 6ce7165abc98c6a55c314c5ea9add5a96abd7e3d
4
+ data.tar.gz: 2252458242c7cbcc967e0acaf39e0ae54d71e3f3
5
5
  SHA512:
6
- metadata.gz: a3cbf7dc3e11e6096d2e39ec2d4938fbe614f3064ef486024f509781943b7ef94299e2e51705bdcb40c8ddd0fbb4e1c7262559cefe4c73ae107caa0fafa5bbad
7
- data.tar.gz: ad5993bb652467ad5ca2909b9cc9690c35fd2aa51a64f09e5407152df31b3fd2ebc4f6a692f126ed853a568fe6a08d631bcd198a46bc155ce9104adc9993ee1f
6
+ metadata.gz: 4701e0e3d22d36a9d2fb301f766f09d3cbd4322d5ca6780bf6912ad5078ab7d2445cc835f478ecd1628f860a356ddea4d38b548266793858e3307b6b608d2cc6
7
+ data.tar.gz: fc033abf703a2969f79af6c6aa1b059395466f5b37afc29c0dfabed5feabadd75455a48c6ec51b864ab641e0147898ce9360012db5e848a54559684b679a8bc5
@@ -1,7 +1,5 @@
1
1
  module PushToSNS
2
2
  class AndroidPushNotification < BasicPushNotification
3
- DEFAULT_MESSAGE = "Android Push Notification"
4
-
5
3
  def message
6
4
  { GCM: { data: default_payload.deeper_merge(payload) }.to_json }
7
5
  end
@@ -9,13 +7,13 @@ module PushToSNS
9
7
  private
10
8
 
11
9
  def default_payload
12
- basic_message = {
13
- message: payload[:message] || DEFAULT_MESSAGE
14
- }
15
- basic_message[:smallIcon] = payload[:badge] if payload[:badge]
16
- basic_message[:sound] = payload[:sound] if payload[:sound]
10
+ basic_payload = {}
11
+ basic_payload[:title] = payload[:title] if payload[:title]
12
+ basic_payload[:message] = payload[:message] if payload[:message]
13
+ basic_payload[:smallIcon] = payload[:small_icon] if payload[:small_icon]
14
+ basic_payload[:sound] = payload[:sound] if payload[:sound]
17
15
 
18
- basic_message
16
+ basic_payload
19
17
  end
20
18
  end
21
19
  end
@@ -1,21 +1,23 @@
1
1
  module PushToSNS
2
2
  class IosPushNotification < BasicPushNotification
3
- DEFAULT_MESSAGE = "IOS Push Notification"
4
-
5
3
  def message
6
4
  basic_message = {
7
5
  apns => {
8
- aps: {
9
- alert: payload[:message] || DEFAULT_MESSAGE
10
- }.merge(payload)
11
- }
6
+ aps: default_payload.merge(payload)
7
+ }.to_json
12
8
  }
13
- basic_message[apns][:aps][:badge] = payload[:badge] if payload[:badge]
14
- basic_message[apns][:aps][:sound] = payload[:sound] if payload[:sound]
15
- basic_message[apns] = basic_message[apns].to_json
16
9
  basic_message
17
10
  end
18
11
 
12
+ def default_payload
13
+ basic_payload = {}
14
+ basic_payload[:title] = payload[:title] if payload[:title]
15
+ basic_payload[:alert] = payload[:message] if payload[:message]
16
+ basic_payload[:badge] = payload[:badge] if payload[:badge]
17
+ basic_payload[:sound] = payload[:sound] if payload[:sound]
18
+ basic_payload
19
+ end
20
+
19
21
  private
20
22
 
21
23
  def apns
@@ -52,6 +52,14 @@ module PushToSNS
52
52
  @sound ||= self.class.sound
53
53
  end
54
54
 
55
+ def title
56
+ @title ||= self.class.title
57
+ end
58
+
59
+ def small_icon
60
+ @small_icon ||= self.class.small_icon
61
+ end
62
+
55
63
  private
56
64
 
57
65
  def call_or_read(proc_or_object, *arguments)
@@ -63,7 +71,7 @@ module PushToSNS
63
71
  end
64
72
 
65
73
  class << self
66
- [:type, :message, :badge, :sound].each do |method_name|
74
+ [:type, :message, :badge, :sound, :title, :small_icon].each do |method_name|
67
75
  property_name = "input_#{method_name}".to_sym
68
76
  attr_accessor property_name
69
77
 
@@ -1,3 +1,3 @@
1
1
  module PushToSNS
2
- VERSION = "0.3.3"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: push_to_sns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - juliogarciag
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-13 00:00:00.000000000 Z
11
+ date: 2015-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler