Permalink
Browse files

Update lib/apn_on_rails/app/models/apn/group_notification.rb

fix for rails 3 utf8 issue (combining US-ASCII string with UTF-8 string)
  • Loading branch information...
1 parent ba7ba6c commit af30c4776cba9cd1c1f93e0a7ce9aaef7eea5cd4 @ramigg committed Sep 3, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/apn_on_rails/app/models/apn/group_notification.rb
@@ -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

0 comments on commit af30c47

Please sign in to comment.