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.8.6'.freeze

Class Method Summary collapse

Class Method Details

.apns_clientObject



65
66
67
68
69
70
71
72
73
# File 'lib/bmo.rb', line 65

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

.configurationObject



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

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

.configuration=(configuration) ⇒ Object

Help ? rubocop:disable TrivialAccessors



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

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

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

class Configuration

Yields:



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

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

.gcm_clientObject



75
76
77
78
79
# File 'lib/bmo.rb', line 75

def self.gcm_client
  conf   = BMO.configuration.gcm
  GCM::Client.new(conf.gateway_url,
                  conf.api_key)
end

.ios_feedbackArray<FeedbackTuple>

Get the iOS Feedback tuples

Returns:

  • (Array<FeedbackTuple>)

    Feedback Object containing a time and a token



44
45
46
# File 'lib/bmo.rb', line 44

def self.ios_feedback
  apns_client.feedback
end

.reset_configurationObject

rubocop:enable



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

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:



57
58
59
60
61
# File 'lib/bmo.rb', line 57

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

.send_ios_notification(device_token, data) ⇒ Object

Send ios notification with the configuration of BMO

(see #BMO::Configuration)

Parameters:

  • device_token (String)
  • data (Hash)

    The data you want to send

Returns:

  • The Socket#write return

See Also:



34
35
36
37
38
# File 'lib/bmo.rb', line 34

def self.send_ios_notification(device_token, data)
  notification = APNS::Notification.new(device_token, data)
  notification.validate!
  apns_client.send_notification(notification)
end