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 2888ed69fb24512745f175ef0a54ac2a7d8c922c 1 parent 5a2911a
niku authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/apn_on_rails/app/models/apn/notification.rb
10 lib/apn_on_rails/app/models/apn/notification.rb
View
@@ -79,9 +79,13 @@ def to_apple_json
# Creates the binary message needed to send to Apple.
def message_for_sending
- json = self.to_apple_json
- message = "\0\0 #{self.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 = self.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.