Skip to content

Instantly share code, notes, and snippets.

@3dd13
Created December 19, 2012 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3dd13/4335732 to your computer and use it in GitHub Desktop.
Save 3dd13/4335732 to your computer and use it in GitHub Desktop.
Convert the apn token collected from iOS to the format apn_on_rails is expecting
# the apn push token you collected from mobile is in this format:
# 00ea74e76a873e8e9c14c2dd2afe3b42abb35148e94042811e2b6985072641f2
#
# but actually, apn_on_rails is expecting this:
# 00ea74e7 6a873e8e 9c14c2dd 2afe3b42 abb35148 e9404281 1e2b6985 072641f2
def format_apn_token(text)
text && text.gsub(/(.{8})(?=.)/, '\1 \2')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment