Module: NotifyPush::Sender
- Defined in:
- lib/notify-push.rb
Overview
MODULE->SENDER ——————————-
Class Method Summary collapse
Class Method Details
.start ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/notify-push.rb', line 89 def self.start() # The only thing we require is a message. # The others will be nil if not supplied. raise "No message supplied." if ARGV[0].blank? 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 |