Class: Getui::Apns

Inherits:
Object
  • Object
show all
Defined in:
lib/getui/apple.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, title: "", payload: nil) ⇒ Apns

Returns a new instance of Apns.



4
5
6
7
8
9
10
# File 'lib/getui/apple.rb', line 4

def initialize(body, title: "", payload: nil)
  @body = body
  @title = title
  @auto_badge = "1"
  @payload = payload
  @sound = "default"
end

Instance Attribute Details

#auto_badgeObject

Returns the value of attribute auto_badge.



3
4
5
# File 'lib/getui/apple.rb', line 3

def auto_badge
  @auto_badge
end

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/getui/apple.rb', line 3

def body
  @body
end

#payloadObject

Returns the value of attribute payload.



3
4
5
# File 'lib/getui/apple.rb', line 3

def payload
  @payload
end

#soundObject

Returns the value of attribute sound.



3
4
5
# File 'lib/getui/apple.rb', line 3

def sound
  @sound
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/getui/apple.rb', line 3

def title
  @title
end

Instance Method Details

#as_jsonObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/getui/apple.rb', line 12

def as_json
  {
   aps: {
         alert: {
                 body: self.body,
                 title: self.title,
                },
         autoBadge: self.auto_badge,
         sound: self.sound,
        },
   payload: payload,
  }
end