Sha256: 44672af538c51409062925b356606e4573cc9c644d6b3e344848a02e77e33855

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require "fwt_push_notification_server/engine"
require 'notifier/base'
require 'notifier/apns'
require 'notifier/gcm'

module FwtPushNotificationServer

  mattr_accessor :api_controller_class

  mattr_accessor :user_class

  mattr_accessor :permitted_user_attributes

  mattr_accessor :user_key
  @@user_key = :user_id  

  mattr_accessor :apns_gateway
  @@apns_gateway = 'sandbox.push.apple.com'

  mattr_accessor :apns_certificate

  mattr_accessor :apns_passphrase

  mattr_accessor :gcm_api_key

  def self.configure
    yield self
  end

  ###
  # Push Notifications
  ###

  mattr_accessor :notifiers
  @@notifiers = {
    :apns => Notifier::APNS.new,
    :gcm => Notifier::GCM.new
  }

  def self.apns_config
    {
      :gateway => apns_gateway,
      :certificate => apns_certificate,
      :passphrase => apns_passphrase
    }
  end

  def self.begin_transaction(message, payload = nil)
    notifiers.each_value do |notifier|
      notifier.begin_transaction(message, payload)
    end
  end

  def self.commit_transaction
    notifiers.each_value do |notifier|
      notifier.commit_transaction
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fwt_push_notification_server-0.1.0.b7 lib/fwt_push_notification_server.rb
fwt_push_notification_server-0.1.0.b6 lib/fwt_push_notification_server.rb
fwt_push_notification_server-0.1.0.b5 lib/fwt_push_notification_server.rb