Class: Rpush::Daemon::Wns::ToastRequestPayload
- Inherits:
-
Object
- Object
- Rpush::Daemon::Wns::ToastRequestPayload
- Defined in:
- lib/rpush/daemon/wns/toast_request.rb
Instance Method Summary collapse
-
#initialize(notification) ⇒ ToastRequestPayload
constructor
A new instance of ToastRequestPayload.
- #to_xml ⇒ Object
Constructor Details
#initialize(notification) ⇒ ToastRequestPayload
Returns a new instance of ToastRequestPayload.
26 27 28 29 30 31 |
# File 'lib/rpush/daemon/wns/toast_request.rb', line 26 def initialize(notification) @title = notification.data['title'] || '' @body = notification.data['body'] || '' @launch = notification.data['launch'] @sound = notification.sound unless notification.sound.eql?("default".freeze) end |
Instance Method Details
#to_xml ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rpush/daemon/wns/toast_request.rb', line 33 def to_xml launch_string = "" unless @launch launch_string = " launch='#{CleanParamString.clean(@launch)}'" if @launch audio_string = "" unless @sound audio_string = "<audio src='#{CleanParamString.clean(@sound)}'/>" if @sound "<toast#{launch_string}> <visual version='1' lang='en-US'> <binding template='ToastText02'> <text id='1'>#{CleanParamString.clean(@title)}</text> <text id='2'>#{CleanParamString.clean(@body)}</text> </binding> </visual> #{audio_string} </toast>" end |