Class: Unipush::WinPhone_push
- Inherits:
-
Object
- Object
- Unipush::WinPhone_push
- Defined in:
- lib/unipush.rb
Overview
Windows Phone
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
Instance Method Summary collapse
-
#initialize ⇒ WinPhone_push
constructor
A new instance of WinPhone_push.
-
#send_tile(device_urls, title, bg_image, count, back_title = nil, back_text = nil, back_bg_image = nil) ⇒ Object
send_tile().
-
#send_toast(device_urls, text1, text2 = nil) ⇒ Object
send_toast().
Constructor Details
#initialize ⇒ WinPhone_push
Returns a new instance of WinPhone_push.
361 362 363 364 365 366 367 368 369 |
# File 'lib/unipush.rb', line 361 def initialize @client_id = nil @client_secret = nil @auth_token_url = 'https://login.live.com/accesstoken.srf' @access_token = nil @last_error = [] end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
358 359 360 |
# File 'lib/unipush.rb', line 358 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
358 359 360 |
# File 'lib/unipush.rb', line 358 def client_secret @client_secret end |
Instance Method Details
#send_tile(device_urls, title, bg_image, count, back_title = nil, back_text = nil, back_bg_image = nil) ⇒ Object
send_tile()
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/unipush.rb', line 376 def send_tile(device_urls, title, bg_image, count, back_title=nil, back_text=nil, back_bg_image=nil) if device_urls && title builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml['wp'].Notification('xmlns:wp'=>'WPNotification') do xml['wp'].Tile{ xml['wp'].BackgroundImage{ xml.text bg_image } xml['wp'].Title{ xml.text title } xml['wp'].Count{ xml.text count.to_s } if back_title xml['wp'].BackTitle{ xml.text back_title } end if back_text xml['wp'].BackContent{ xml.text back_text } end if back_bg_image xml['wp'].BackBackgroundImage{ xml.text back_bg_image } end } end end content = builder.to_xml puts content headers = { 'X-WindowsPhone-Target' => 'token', 'Content-Type' => 'text/xml', 'X-NotificationClass' => '1', 'Content-Length' => content.bytesize.to_s } (headers, content, device_urls) else @last_error.push('no data') false end end |
#send_toast(device_urls, text1, text2 = nil) ⇒ Object
send_toast()
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/unipush.rb', line 434 def send_toast(device_urls, text1, text2=nil) if device_urls && text1 builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml['wp'].Notification('xmlns:wp'=>'WPNotification') do xml['wp'].Toast{ xml['wp'].Text1{ xml.text text1 } if text2 xml['wp'].Text2{ xml.text text2 } end } end end content = builder.to_xml headers = { 'X-WindowsPhone-Target' => 'toast', 'Content-Type' => 'text/xml', 'X-NotificationClass' => '2', 'Content-Length' => content.bytesize.to_s } (headers, content, device_urls) else @last_error.push('no data') false end end |