Sha256: b68d6447244221db7483313add5530fef9f98cfb94e168cb6108106eabab4c8f

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

require 'xinge/base'
module Xinge
  class Ios < Base

    ENV_MAP = {'production' => 1, 'development' => 2}

    def initialize(accessId = nil, secretKey = nil, options = {})
      super
    end
    def pushToSingleDevice(token, title, content, params={})
      self.push_single_device(token, 1, build_simple_message(title, content), {environment: ENV_MAP[Xinge.config[:env]]})
    end
    def pushToAllDevice(title, content, params={})
      self.push_all_device(1, build_simple_message(title, content), {environment: ENV_MAP[Xinge.config[:env]]})
    end

    protected

    def build_simple_message(title,content)
      {
        aps: {
          alert: {
            title: title,
            body: content
          },
          sound: 'default',
          badge: 5
        }
      }.to_json
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-for-xinge-0.1.1 lib/xinge/ios.rb