Sha256: ccf0f2d506e9046f0cd4e7290d626d9c7e5af39124c40ecf5b9ed0e66441e5a1
Contents?: true
Size: 970 Bytes
Versions: 1
Compression:
Stored size: 970 Bytes
Contents
require 'securerandom' require 'json' module Apnotic class Notification attr_reader :token attr_accessor :alert, :badge, :sound, :content_available, :category, :custom_payload, :url_args, :mutable_content attr_accessor :apns_id, :expiration, :priority, :topic def initialize(token) @token = token @apns_id = SecureRandom.uuid end def body JSON.dump(to_hash).force_encoding(Encoding::BINARY) end private def to_hash aps = {} aps.merge!(alert: alert) if alert aps.merge!(badge: badge) if badge aps.merge!(sound: sound) if sound aps.merge!(category: category) if category aps.merge!('content-available' => content_available) if content_available aps.merge!('url-args' => url_args) if url_args aps.merge!('mutable-content' => mutable_content) if mutable_content n = { aps: aps } n.merge!(custom_payload) if custom_payload n end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
apnotic-0.10.0 | lib/apnotic/notification.rb |