Sha256: 1235727670f41f678f1d0bd54ad4afd6043a1142cd7e1cb9e7a11f3b97df5c3f

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 Bytes

Contents

module NotifyUser
  class Push
    SYMBOL_NAMES_SIZE = 10
    PAYLOAD_LIMIT = 255

    def initialize(notifications, devices, options)
      @notifications = notifications
      @notification = notifications.first

      @devices = devices
      @options = options
    end

    # Sends push notification:
    def push
      raise "Base APNS class should not be used."
    end

    private

    attr_accessor :device_tokens

    def device_tokens
      @device_tokens = @devices.map(&:token)
    end

    # Calculates the bytes already used:
    def used_space
      used_space = SYMBOL_NAMES_SIZE + @notification.id.size + @notification.created_at.to_time.to_i.size +
                    @notification.type.size

      used_space += @notification.params[:action_id].size if @notification.params[:action_id]

      used_space
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
notify_user-0.3.2 app/models/notify_user/push.rb
notify_user-0.3.1 app/models/notify_user/push.rb