Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't encode utf8 strings before sending to apple. This allows longer…

… messages
  • Loading branch information...
commit 16b33ebdcaa2975543e02fb7bdb948bb20becbdd 1 parent bea6a21
Rami Grossman authored
2  lib/apn_on_rails/app/models/apn/group_notification.rb
View
@@ -70,7 +70,7 @@ def to_apple_json
# Creates the binary message needed to send to Apple.
def message_for_sending(device)
- json = self.to_apple_json
+ json = self.to_apple_json.gsub!(/\\u([0-9a-z]{4})/) {|s| [$1.to_i(16)].pack("U")} # This will create non encoded string. Otherwise the string is encoded from utf8 to ascii with unicode representation (i.e. \\u05d2)
message = "\0\0 #{device.to_hexa}\0#{json.length.chr}#{json}"
raise APN::Errors::ExceededMessageSizeError.new(message) if message.size.to_i > 256
message
2  lib/apn_on_rails/app/models/apn/notification.rb
View
@@ -79,7 +79,7 @@ def to_apple_json
# Creates the binary message needed to send to Apple.
def message_for_sending
- json = self.to_apple_json
+ json = self.to_apple_json.gsub!(/\\u([0-9a-z]{4})/) {|s| [$1.to_i(16)].pack("U")} # This will create non encoded string. Otherwise the string is encoded from utf8 to ascii with unicode representation (i.e. \\u05d2)
message = "\0\0 #{self.device.to_hexa}\0#{json.length.chr}#{json}"
raise APN::Errors::ExceededMessageSizeError.new(message) if message.size.to_i > 256
message
Please sign in to comment.
Something went wrong with that request. Please try again.