Sha256: 71261feb649b72834d54cde132f107d83504c5cfe48ef9ac31f4328029649d7e
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module NotifyUser class PubNub #sends push notification def self.push_notification(notification) pubnub = Pubnub.new( :origin => ENV['PN_ORIGIN'], :publish_key => ENV['PN_PUBLISH_KEY'], :subscribe_key => ENV['PN_SUBSCRIBE_KEY'], :secret_key => ENV['PN_SECRET_KEY'], :logger => Logger.new(STDOUT) ) pubnub.grant( auth_key: ENV['PN_SECRET_KEY'], :read => true, :write => true, :ttl => 525600, :http_sync => true ) pn_apns = { aps: { alert: notification.mobile_message, badge: 1, type: notification.type } } pn_apns[:aps][:action_id] = notification.params[:action_id] if notification.params[:action_id] pn_apns[:aps]['content-available'] = notification.params['content-available'] if notification.params['content-available'] pn_gcm = { message: notification.mobile_message, type: notification.type } pn_gcm[:action_id] = notification.params[:action_id] if notification.params[:action_id] pubnub.publish( channel: notification.target.uuid, http_sync: true, message: { pn_apns: pn_apns, pn_gcm: pn_gcm } ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
notify_user-0.0.26 | app/models/notify_user/pub_nub.rb |