class Pushwoosh::PushNotification
Constants
- STRING_BYTE_LIMIT
Attributes
auth_hash[R]
Public Class Methods
new(auth_hash = {})
click to toggle source
# File lib/pushwoosh/push_notification.rb, line 13 def initialize(auth_hash = {}) @auth_hash = auth_hash end
Public Instance Methods
notify_all(message, other_options = {})
click to toggle source
# File lib/pushwoosh/push_notification.rb, line 17 def notify_all(message, other_options = {}) other_options.merge!(content: limited_content(message)) create_message(other_options) end
notify_devices(message, devices, other_options = {})
click to toggle source
# File lib/pushwoosh/push_notification.rb, line 22 def notify_devices(message, devices, other_options = {}) other_options.merge!(content: limited_content(message), devices: devices) create_message(other_options) end
Private Instance Methods
build_notification_options(notification_options)
click to toggle source
# File lib/pushwoosh/push_notification.rb, line 41 def build_notification_options(notification_options) { notification_options: default_notification_options.merge(notification_options) }.merge(auth_hash) end
create_message(notification_options = {})
click to toggle source
# File lib/pushwoosh/push_notification.rb, line 35 def create_message(notification_options = {}) fail Pushwoosh::Exceptions::Error, 'Message is missing' if notification_options[:content].nil? || notification_options[:content].empty? Request.make_post!('/createMessage', build_notification_options(notification_options)) end
default_notification_options()
click to toggle source
# File lib/pushwoosh/push_notification.rb, line 45 def default_notification_options { send_date: "now", ios_badges: "+1" } end
limited_content(message)
click to toggle source
# File lib/pushwoosh/push_notification.rb, line 31 def limited_content(message) Helpers.limit_string(message, STRING_BYTE_LIMIT) end