Class: Nuge::Clients::Urbanairship

Inherits:
Object
  • Object
show all
Defined in:
lib/nuge/clients/urbanairship.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Urbanairship

Returns a new instance of Urbanairship.



9
10
11
12
# File 'lib/nuge/clients/urbanairship.rb', line 9

def initialize(options = {})
  @expander = options[:expander]
  @options  = options
end

Instance Attribute Details

#expander=(value) ⇒ Object (writeonly)

Sets the attribute expander

Parameters:

  • value

    the value to set the attribute expander to.



7
8
9
# File 'lib/nuge/clients/urbanairship.rb', line 7

def expander=(value)
  @expander = value
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/nuge/clients/urbanairship.rb', line 6

def options
  @options
end

Instance Method Details

#push(ids, message) ⇒ Object



30
31
32
33
34
# File 'lib/nuge/clients/urbanairship.rb', line 30

def push(ids, message)
  formatter = message.delete(:formatter) || Nuge::Formatters::Aps

  pusher.push(formatter.call(ids, message))
end

#pusherObject



14
15
16
17
18
19
20
# File 'lib/nuge/clients/urbanairship.rb', line 14

def pusher
  @pusher ||= ::Urbanairship.tap do |serv|
    serv.application_key    = options[:application_key]
    serv.application_secret = options[:application_secret]
    serv.master_secret      = options[:master_secret]
  end
end

#register(id, options = {}) ⇒ Object



22
23
24
# File 'lib/nuge/clients/urbanairship.rb', line 22

def register(id, options = {})
  pusher.register_device(id, options)
end

#unregister(id, options = {}) ⇒ Object



26
27
28
# File 'lib/nuge/clients/urbanairship.rb', line 26

def unregister(id, options = {})
  pusher.unregister_device(id, options)
end