module BMO

Main BMO namespace

Main BMO module

Main BMO module, version get right here

Constants

VERSION

Public Class Methods

configuration() click to toggle source
# File lib/bmo/configuration.rb, line 50
def self.configuration
  @configuration ||= Configuration.new
end
configuration=(configuration) click to toggle source

Help ? rubocop:disable TrivialAccessors

# File lib/bmo/configuration.rb, line 56
def self.configuration=(configuration)
  @configuration = configuration
end
configure() { |configuration| ... } click to toggle source
# File lib/bmo/configuration.rb, line 45
def self.configure
  yield(configuration) if block_given?
  configuration
end
ios_feedback() click to toggle source

Get the iOS Feedback tuples

@return [Array<FeedbackTuple>] Feedback Object containing

a time and a token
# File lib/bmo.rb, line 46
def self.ios_feedback
  apns_client.feedback
end
reset_configuration() click to toggle source

rubocop:enable

# File lib/bmo/configuration.rb, line 61
def self.reset_configuration
  @configuration = Configuration.new
end
send_android_notification(device_token, data) click to toggle source

Send android notification with the configuration of BMO

(see #BMO::Configuration)

@param device_token [String] @param data [Hash] The data you want to send

@return [Faraday::Response] The HTTP Response

@see developer.android.com/google/gcm/server.html]

# 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 = {}) click to toggle source

Send ios notification with the configuration of BMO

(see #BMO::Configuration)

@param device_token [String] @param data [Hash] The data you want to send @option options :truncable_alert If the payload is too large

this alert field will be truncated

@option options :omission ('…') The omission in truncate @option options :separator The separator use in truncation

@return The Socket#write return

@see developer.apple.com/library/ios/documentation/

NetworkingInternet/Conceptual/RemoteNotificationsPG/
Chapters/ApplePushService.html
# 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

Private Class Methods

apns_client() click to toggle source
# File lib/bmo.rb, line 67
def self.apns_client
  conf   = BMO.configuration.apns
  APNS::Client.new(conf.gateway_host,
                   conf.gateway_port,
                   conf.feedback_host,
                   conf.feedback_port,
                   cert_path: conf.cert_path,
                   cert_pass: conf.cert_pass)
end
gcm_client() click to toggle source
# File lib/bmo.rb, line 77
def self.gcm_client
  conf   = BMO.configuration.gcm
  GCM::Client.new(conf.gateway_url,
                  conf.api_key)
end