Sha256: 0a59ae17aa4d5e90cd5dd6f1c571ae5fab5b7ac40c52a2b407f0f61f9968ba3a

Contents?: true

Size: 908 Bytes

Versions: 4

Compression:

Stored size: 908 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, :thread_id

    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
        result.merge!('thread-id' => thread_id) if thread_id
      end
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
apnotic-1.5.0 lib/apnotic/notification.rb
apnotic-1.4.1 lib/apnotic/notification.rb
apnotic-1.4.0 lib/apnotic/notification.rb
apnotic-1.3.1 lib/apnotic/notification.rb