module Agilib::PushNotification::Model
Public Instance Methods
send_push_notification(message, data = {}, platforms = :all)
click to toggle source
# File lib/agilib/push_notification/model.rb, line 8 def send_push_notification(message, data = {}, platforms = :all) @platforms = Hash.new @devices = self.devices.all @responses = Hash.new message = message[0,50] unless platforms.is_a? Array if platforms.to_sym == :all @platforms = Agilib::PushNotification.avaiable_platforms else @platforms[platforms] = Agilib::PushNotification.avaiable_platforms[platforms] end else platforms.each do |platform| @platforms[platform] = Agilib::PushNotification.avaiable_platforms[platform] if Agilib::PushNotification.avaiable_platforms.has_key?(platform) end end @devices.each do |device| if @platforms.has_key? device.platform.to_sym platform = @platforms[device.platform.to_sym] @responses[device.platform.to_sym] = platform.send_notification(message, data, device) end end return @responses end