def packaged_message
      @packaged_message ||=
        begin
          opts = @options.dup
          hsh = {'aps' => {}}
          if alert = opts.delete(:alert)
            alert = alert.to_s unless alert.is_a?(Hash)
            hsh['aps']['alert'] = alert
          end
          hsh['aps']['badge'] = opts.delete(:badge).to_i if opts[:badge]
          hsh['aps']['category'] = opts.delete(:category).to_s if opts[:category]
          if sound = opts.delete(:sound)
            hsh['aps']['sound'] = sound.is_a?(TrueClass) ? 'default' : sound.to_s
          end
          if content_available = opts.delete(:content_available)
            hsh['aps']['content-available'] = 1 if [1,true].include? content_available
          end
          hsh.merge!(opts)
          Payload.new(hsh, DATA_MAX_BYTES).package
        end
    end
def packaged_message
      @packaged_message ||=
        begin
          opts = @options.dup
          hsh = {'aps' => {}}
          if alert = opts.delete(:alert)
            alert = alert.to_s unless alert.is_a?(Hash)
            hsh['aps']['alert'] = alert
          end
          hsh['aps']['badge'] = opts.delete(:badge).to_i if opts[:badge]
          hsh['aps']['category'] = opts.delete(:category).to_s if opts[:category]
          if sound = opts.delete(:sound)
            hsh['aps']['sound'] = sound.is_a?(TrueClass) ? 'default' : sound.to_s
          end
          if content_available = opts.delete(:content_available)
            hsh['aps']['content-available'] = 1 if [1,true].include? content_available
          end
          hsh.merge!(opts)
          Payload.new(hsh, DATA_MAX_BYTES).package
        end
    end
Converts the supplied options into the JSON needed for Apple's push notification servers.
 Extracts :alert, :badge, :sound and :category keys into the 'aps' hash, merges any other hash data
 into the root of the hash to encode and send to apple.