class Pushr::MessageApns2
Constants
- POSTFIX
Attributes
alert[RW]
apns_collapse_id[RW]
apns_expiration[RW]
apns_id[RW]
apns_priority[RW]
apns_topic[RW]
badge[RW]
category[RW]
content_available[RW]
custom_payload[RW]
mutable_content[RW]
sound[RW]
token[RW]
url_args[RW]
Public Instance Methods
body()
click to toggle source
# File lib/pushr/message_apns2.rb, line 14 def body JSON.dump(to_message).force_encoding(Encoding::BINARY) end
to_hash()
click to toggle source
# File lib/pushr/message_apns2.rb, line 18 def to_hash hsh = { type: self.class.to_s, app: app, token: token, alert: alert, badge: badge, sound: sound, category: category, content_available: content_available, mutable_content: mutable_content, url_args: url_args, apns_id: apns_id, apns_expiration: apns_expiration, apns_priority: apns_priority, apns_topic: apns_topic, apns_collapse_id: apns_collapse_id, custom_payload: custom_payload } hsh[Pushr::Core.external_id_tag] = external_id if external_id hsh end
Private Instance Methods
priority_with_content_available()
click to toggle source
# File lib/pushr/message_apns2.rb, line 44 def priority_with_content_available if content_available == 1 && apns_priority != 5 && !(alert || badge || sound) errors.add(:apns_priority, 'Priority should be 5 if content_available = 1 and no alert/badge/sound') end end
to_message()
click to toggle source
# File lib/pushr/message_apns2.rb, line 29 def to_message aps = {} aps[:alert] = alert if alert aps[:badge] = badge if badge aps[:sound] = sound if sound aps[:category] = category if category aps['content-available'] = content_available if content_available aps['url-args'] = url_args if url_args aps['mutable-content'] = mutable_content if mutable_content n = { aps: aps } n.merge!(custom_payload) if custom_payload n end