Module: NotifyPush::Sender
- Defined in:
- lib/notify-push/sender.rb
Overview
MODULE->SENDER ——————————-
Class Method Summary collapse
Class Method Details
.send_notification ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/notify-push/sender.rb', line 15 def self.send_notification() ARGV.shift # The only thing we require is a message. # The others will be nil if not supplied. raise "No message supplied." if ARGV[0].blank? ::NotifyPush.acting_as = self notification = { message: ARGV[0], title: ARGV[1], subtitle: ARGV[2] } puts "Sending notification (backgrounded) with data:" puts " message-> #{notification[:message]}" puts " title-> #{notification[:title]}" puts " subtitle-> #{notification[:subtitle]}" # Daemonize now. Process.daemon true require "pusher" # Strip the nil key/value pairs out so we don't have to # worry about them on the Receiver end. notification.delete_if {|key, value| value.blank?} # Connect to Pusher and trigger the notification Pusher.url = "http://#{configuration.pusher.key}:#{configuration.pusher.secret}@api.pusherapp.com/apps/#{configuration.pusher.app_id}" Pusher[CHANNEL_NAME].trigger("notification", notification) 0 end |