Sha256: 5b9eb35b4de005f3debd7e37d7688b69b032d4246114c61d9f54f0dd4c8fac9b

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

require 'apnotic/abstract_notification'

module Apnotic

  class Notification < AbstractNotification
    attr_accessor :alert, :badge, :sound, :content_available, :category, :custom_payload, :url_args, :mutable_content

    private

    def aps
      {}.tap do |result|
        result.merge!(alert: alert) if alert
        result.merge!(badge: badge) if badge
        result.merge!(sound: sound) if sound
        result.merge!(category: category) if category
        result.merge!('content-available' => content_available) if content_available
        result.merge!('url-args' => url_args) if url_args
        result.merge!('mutable-content' => mutable_content) if mutable_content
      end
    end

    def to_hash
      { aps: aps }.tap do |result|
        result.merge!(custom_payload) if custom_payload
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apnotic-1.3.0 lib/apnotic/notification.rb