Skip to content

Commit

Permalink
Update lib/apn_on_rails/app/models/apn/group_notification.rb
Browse files Browse the repository at this point in the history
fix for rails 3 utf8 issue (combining US-ASCII string with UTF-8 string)
  • Loading branch information
ramigg committed Sep 3, 2012
1 parent ba7ba6c commit af30c47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/apn_on_rails/app/models/apn/group_notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def to_apple_json
# Creates the binary message needed to send to Apple.
def message_for_sending(device)
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}"
message = "\0\0 #{device.to_hexa}\0".force_encoding("UTF-8") + "#{json.length.chr}#{json}".force_encoding("UTF-8")
raise APN::Errors::ExceededMessageSizeError.new(message) if message.size.to_i > 256
message
end
Expand Down

0 comments on commit af30c47

Please sign in to comment.