Class: RubyPushNotifications::APNS::APNSNotification
- Inherits:
-
Object
- Object
- RubyPushNotifications::APNS::APNSNotification
- Includes:
- NotificationResultsManager
- 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
Attributes included from NotificationResultsManager
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
21 22 23 24 |
# File 'lib/ruby-push-notifications/apns/apns_notification.rb', line 21 def initialize(tokens, data) @tokens = tokens @data = data end |
Instance Method Details
#count ⇒ Integer
Returns . The number of binaries this notification will send. One for each receiver.
51 52 53 |
# File 'lib/ruby-push-notifications/apns/apns_notification.rb', line 51 def count @tokens.count end |
#each_message(starting_id) {|.| ... } ⇒ Object
Method that yields the notification’s binary for each of the receivers.
42 43 44 45 46 47 |
# File 'lib/ruby-push-notifications/apns/apns_notification.rb', line 42 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 |