Class: RubyPushNotifications::WNS::WNSPusher

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-push-notifications/wns/wns_pusher.rb

Overview

This class is responsible for sending notifications to the WNS service.

Instance Method Summary collapse

Constructor Details

#initialize(access_token, options = {}) ⇒ WNSPusher

Parameters:

  • access_token (String)

    . WNS access token.

  • options (Hash) (defaults to: {})

    optional. Options for GCMPusher. Currently supports:

    • open_timeout [Integer]: Number of seconds to wait for the connection to open. Defaults to 30.

    • read_timeout [Integer]: Number of seconds to wait for one block to be read. Defaults to 30.



15
16
17
18
# File 'lib/ruby-push-notifications/wns/wns_pusher.rb', line 15

def initialize(access_token, options = {})
  @access_token = access_token
  @options = options
end

Instance Method Details

#push(notifications) ⇒ Object

Actually pushes the given notifications. Assigns every notification an array with the result of each individual notification.

Parameters:

  • notifications (Array)

    . Array of WNSNotification to send.



25
26
27
28
29
# File 'lib/ruby-push-notifications/wns/wns_pusher.rb', line 25

def push(notifications)
  notifications.each do |notif|
    notif.results = WNSConnection.post notif, @access_token, @options
  end
end