Class: RubyPushNotifications::APNS::APNSNotification
- Inherits:
-
Object
- Object
- RubyPushNotifications::APNS::APNSNotification
- Defined in:
- lib/ruby-push-notifications/apns/apns_notification.rb
Overview
Represents a APNS Notification. Manages the conversion of the notification to APNS binary format for each of the destinations. By default sets maximum expiration date (4 weeks).
Constant Summary collapse
- WEEKS_4 =
2419200
Instance Attribute Summary collapse
-
#results ⇒ Array
. Array with the results from sending this notification.
Instance Method Summary collapse
-
#count ⇒ Integer
. The number of binaries this notification will send. One for each receiver..
-
#each_message(starting_id) {|.| ... } ⇒ Object
Method that yields the notification’s binary for each of the receivers.
-
#initialize(tokens, data) ⇒ APNSNotification
constructor
Initializes the APNS Notification.
Constructor Details
#initialize(tokens, data) ⇒ APNSNotification
Initializes the APNS Notification
24 25 26 27 |
# File 'lib/ruby-push-notifications/apns/apns_notification.rb', line 24 def initialize(tokens, data) @tokens = tokens @data = data end |
Instance Attribute Details
#results ⇒ Array
Returns . Array with the results from sending this notification.
18 19 20 |
# File 'lib/ruby-push-notifications/apns/apns_notification.rb', line 18 def results @results end |
Instance Method Details
#count ⇒ Integer
Returns . The number of binaries this notification will send. One for each receiver.
54 55 56 |
# File 'lib/ruby-push-notifications/apns/apns_notification.rb', line 54 def count @tokens.count end |
#each_message(starting_id) {|.| ... } ⇒ Object
Method that yields the notification’s binary for each of the receivers.
45 46 47 48 49 50 |
# File 'lib/ruby-push-notifications/apns/apns_notification.rb', line 45 def (starting_id) @tokens.each_with_index do |token, i| bytes = device_token(token) + payload + notification_id(starting_id + i) + expiration_date + priority yield [2, bytes.bytesize, bytes].pack 'cNa*' end end |