Class: Rapns::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/rapns/config.rb

Overview

A class to hold Rapns configuration settings and callbacks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Initialize the Config with default values



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rapns/config.rb', line 22

def initialize
  super

  # defaults:
  self.foreground = false
  self.push_poll = 2
  self.feedback_poll = 60
  self.airbrake_notify = true
  self.check_for_errors = true
  self.batch_size = 5000
end

Instance Attribute Details

#airbrake_notifyObject

Returns the value of attribute airbrake_notify

Returns:

  • (Object)

    the current value of airbrake_notify



17
18
19
# File 'lib/rapns/config.rb', line 17

def airbrake_notify
  @airbrake_notify
end

#batch_sizeObject

Returns the value of attribute batch_size

Returns:

  • (Object)

    the current value of batch_size



17
18
19
# File 'lib/rapns/config.rb', line 17

def batch_size
  @batch_size
end

#check_for_errorsObject

Returns the value of attribute check_for_errors

Returns:

  • (Object)

    the current value of check_for_errors



17
18
19
# File 'lib/rapns/config.rb', line 17

def check_for_errors
  @check_for_errors
end

#feedback_callbackObject

Returns the value of attribute feedback_callback.



19
20
21
# File 'lib/rapns/config.rb', line 19

def feedback_callback
  @feedback_callback
end

#feedback_pollObject

Returns the value of attribute feedback_poll

Returns:

  • (Object)

    the current value of feedback_poll



17
18
19
# File 'lib/rapns/config.rb', line 17

def feedback_poll
  @feedback_poll
end

#foregroundObject

Returns the value of attribute foreground

Returns:

  • (Object)

    the current value of foreground



17
18
19
# File 'lib/rapns/config.rb', line 17

def foreground
  @foreground
end

#pid_fileObject

Returns the value of attribute pid_file

Returns:

  • (Object)

    the current value of pid_file



17
18
19
# File 'lib/rapns/config.rb', line 17

def pid_file
  @pid_file
end

#push_pollObject

Returns the value of attribute push_poll

Returns:

  • (Object)

    the current value of push_poll



17
18
19
# File 'lib/rapns/config.rb', line 17

def push_poll
  @push_poll
end

Instance Method Details

#on_feedback(&block) ⇒ Object

Define a block that will be executed with a Rapns::Feedback instance when feedback has been received from the push notification servers that a notification has failed to be delivered. Further notifications should not be sent to this device token.

Example usage (in config/initializers/rapns.rb):

Rapns.configure do |config|
  config.on_feedback do |feedback|
    device = Device.find_by_device_token feedback.device_token
    if device
      device.active = false
      device.save
    end
  end
end

Where ‘Device` is a model specific to your Rails app that has a `device_token` field.



51
52
53
# File 'lib/rapns/config.rb', line 51

def on_feedback(&block)
  self.feedback_callback = block
end