Sha256: 538feeffa50ee4a275f517062de124f0e0974f57215cb748a73d73f0807c3a35
Contents?: true
Size: 873 Bytes
Versions: 1
Compression:
Stored size: 873 Bytes
Contents
module Suj module Pusher class ApnNotification include Suj::Pusher::Logger MAX_SIZE = 256 class InvalidToken < StandardError; end class PayloadTooLarge < StandardError; end def initialize(options = {}) @token = options[:token] @options = options raise InvalidToken if @token.nil? || (@token.length != 64) raise PayloadTooLarge if data.size > MAX_SIZE end def payload @payload ||= MultiJson.dump(@options[:data] || {}) end def data @data ||= encode_data end private def encode_data identifier = 0 expiry = 0 size = [payload].pack("a*").size data_array = [1, identifier, expiry, 32, @token, size, payload] info("PAYLOAD: #{data_array}") data_array.pack("cNNnH*na*") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
suj-pusher-0.0.1 | lib/suj/pusher/apn_notification.rb |