class APNConnection

  def initialize
    setup
  end

  def setup
    @uri, @certificate = if Rails.env.production?
      [
        Houston::APPLE_PRODUCTION_GATEWAY_URI,
        File.read("#{Rails.root}/config/keys/production_push.pem")
      ]
    else
      [
        Houston::APPLE_DEVELOPMENT_GATEWAY_URI,
        File.read("#{Rails.root}/config/keys/development_push.pem")
      ]
    end

    @connection = Houston::Connection.new(@uri, @certificate, nil)
    @connection.open
  end

  def ssl
    @connection.ssl
  end

  def connection
    @connection
  end

  def write(data)
    raise "Connection is closed" unless @connection.open?
    @connection.write(data)
  end

end
class APNConnection

  def initialize
    setup
  end

  def setup
    @uri, @certificate = if Rails.env.production? || Rails.env.staging?
      [
        Houston::APPLE_PRODUCTION_GATEWAY_URI,
        File.read("#{Rails.root}/config/keys/production_push.pem")
      ]
    else
      [
        Houston::APPLE_DEVELOPMENT_GATEWAY_URI,
        File.read("#{Rails.root}/config/keys/development_push.pem")
      ]
    end

    @connection = Houston::Connection.new(@uri, @certificate, nil)
    @connection.open
  end

  def ssl
    @connection.ssl
  end

  def connection
    @connection
  end

  def write(data)
    raise "Connection is closed" unless @connection.open?
    @connection.write(data)
  end

end
Make both the staging and production environments use the production gateway and cert. Temp solution for TN, something gets set in the actual project using `notify_user` dictate which gateway it wants to use per environment.
Make both the staging and production environments use the production gateway and cert. Temp solution for TN, something gets set in the actual project using `notify_user` dictate which gateway it wants to use per environment.
