Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

clearly "notification format" of apn specification

  • Loading branch information...
commit 26fc514bfc16a722400affe266149b0667895d3c 1 parent 2888ed6
@niku authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/apn_on_rails/app/models/apn/group_notification.rb
View
10 lib/apn_on_rails/app/models/apn/group_notification.rb
@@ -70,9 +70,13 @@ def to_apple_json
# Creates the binary message needed to send to Apple.
def message_for_sending(device)
- json = self.to_apple_json
- message = "\0\0 #{device.to_hexa}#{[json.length].pack('n')}#{json}"
- raise APN::Errors::ExceededMessageSizeError.new(message) if json.size.to_i > 256
+ command = ['0'].pack('H') # Now, APN_ON_RAILS implements only "simple notification format".
+ token = device.to_hexa
+ token_length = [token.bytesize].pack('n')
+ payload = self.to_apple_json
+ payload_length = [payload.bytesize].pack('n')
+ message = command + token_length + token + payload_length + payload
+ raise APN::Errors::ExceededMessageSizeError.new(message) if payload.bytesize > 256
message
end
Please sign in to comment.
Something went wrong with that request. Please try again.