Class: JPush::IOSNotification
- Inherits:
-
Object
- Object
- JPush::IOSNotification
- Defined in:
- lib/jpush/model/notification/ios_notification.rb
Instance Attribute Summary collapse
-
#alert ⇒ Object
Returns the value of attribute alert.
-
#badge ⇒ Object
Returns the value of attribute badge.
-
#category ⇒ Object
Returns the value of attribute category.
-
#content_available ⇒ Object
Returns the value of attribute content_available.
-
#extras ⇒ Object
Returns the value of attribute extras.
-
#sound ⇒ Object
Returns the value of attribute sound.
Class Method Summary collapse
Instance Method Summary collapse
- #disableBadge ⇒ Object
- #disableSound ⇒ Object
-
#initialize(opts = {}) ⇒ IOSNotification
constructor
A new instance of IOSNotification.
- #toJSON ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ IOSNotification
Returns a new instance of IOSNotification.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 4 def initialize(opts = {}) if opts[:badge] != nil @badge = opts[:badge] else @badge = 1 end if opts[:sound] != nil @sound = opts[:sound] else @sound = '' end @alert = opts[:alert] @extras = opts[:extras] @content_available = opts[:content_available] @category = opts[:category] end |
Instance Attribute Details
#alert ⇒ Object
Returns the value of attribute alert.
3 4 5 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 3 def alert @alert end |
#badge ⇒ Object
Returns the value of attribute badge.
3 4 5 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 3 def badge @badge end |
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 3 def category @category end |
#content_available ⇒ Object
Returns the value of attribute content_available.
3 4 5 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 3 def content_available @content_available end |
#extras ⇒ Object
Returns the value of attribute extras.
3 4 5 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 3 def extras @extras end |
#sound ⇒ Object
Returns the value of attribute sound.
3 4 5 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 3 def sound @sound end |
Class Method Details
.build(opts = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 52 def self.build(opts = {}) ios = JPush::IOSNotification.new(opts) if ios.alert == nil raise ArgumentError.new('the alert should be setted') end if ios.to_s.bytesize > 220 raise ArgumentError.new('ios notfication size is longer than 220 ') end return ios end |
Instance Method Details
#disableBadge ⇒ Object
48 49 50 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 48 def disableBadge @badge = false end |
#disableSound ⇒ Object
44 45 46 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 44 def disableSound @sound = false end |
#toJSON ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jpush/model/notification/ios_notification.rb', line 21 def toJSON array = {} if @alert != nil then array['alert'] = @alert end if @sound != nil && @sound != false then array['sound'] = @sound end if @badge != nil && @badge != false then array['badge'] = @badge end if @extras != nil then array['extras'] = @extras end if @content_available != nil then array['content-available'] = @content_available end if @category != nil then array['category'] = @category end return array end |