Module: BMO

Defined in:
lib/bmo.rb,
lib/bmo/utils.rb,
lib/bmo/version.rb,
lib/bmo/gcm/client.rb,
lib/bmo/apns/client.rb,
lib/bmo/configuration.rb,
lib/bmo/gcm/connection.rb,
lib/bmo/apns/connection.rb,
lib/bmo/gcm/notification.rb,
lib/bmo/apns/notification.rb

Overview

Main BMO module

Defined Under Namespace

Modules: APNS, GCM, Utils Classes: Configuration

Constant Summary collapse

VERSION =
'0.11.2'.freeze

Class Method Summary collapse

Class Method Details

.configurationObject



50
51
52
# File 'lib/bmo/configuration.rb', line 50

def self.configuration
  @configuration ||= Configuration.new
end

.configuration=(configuration) ⇒ Object

Help ? rubocop:disable TrivialAccessors



56
57
58
# File 'lib/bmo/configuration.rb', line 56

def self.configuration=(configuration)
  @configuration = configuration
end

.configure {|configuration| ... } ⇒ Object

class Configuration

Yields:



45
46
47
48
# File 'lib/bmo/configuration.rb', line 45

def self.configure
  yield(configuration) if block_given?
  configuration
end

.ios_feedbackArray<FeedbackTuple>

Get the iOS Feedback tuples

Returns:

  • (Array<FeedbackTuple>)

    Feedback Object containing a time and a token



46
47
48
# File 'lib/bmo.rb', line 46

def self.ios_feedback
  apns_client.feedback
end

.reset_configurationObject

rubocop:enable



61
62
63
# File 'lib/bmo/configuration.rb', line 61

def self.reset_configuration
  @configuration = Configuration.new
end

.send_android_notification(device_token, data) ⇒ Faraday::Response

Send android notification with the configuration of BMO

(see #BMO::Configuration)

Parameters:

  • device_token (String)
  • data (Hash)

    The data you want to send

Returns:

  • (Faraday::Response)

    The HTTP Response

See Also:



59
60
61
62
63
# File 'lib/bmo.rb', line 59

def self.send_android_notification(device_token, data)
  data = Utils.coerce_to_symbols(data)
  notification = GCM::Notification.new(device_token, data)
  gcm_client.send_notification(notification)
end

.send_ios_notification(device_token, data, options = {}) ⇒ Object

Send ios notification with the configuration of BMO

(see #BMO::Configuration)

Parameters:

  • device_token (String)
  • data (Hash)

    The data you want to send

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

    a customizable set of options

Options Hash (options):

  • :truncable_alert (Object)

    If the payload is too large this alert field will be truncated

  • :omission (Object) — default: '...'

    The omission in truncate

  • :separator (Object)

    The separator use in truncation

Returns:

  • The Socket#write return

See Also:



36
37
38
39
40
# File 'lib/bmo.rb', line 36

def self.send_ios_notification(device_token, data, options = {})
  data = Utils.coerce_to_symbols(data)
  notification = APNS::Notification.new(device_token, data, options)
  apns_client.send_notification(notification)
end