Skip to content

Instantly share code, notes, and snippets.

@3dd13
Created December 19, 2012 10:15
Show Gist options
  • Select an option

  • Save 3dd13/4335732 to your computer and use it in GitHub Desktop.

Select an option

Save 3dd13/4335732 to your computer and use it in GitHub Desktop.

Revisions

  1. 3dd13 created this gist Dec 19, 2012.
    9 changes: 9 additions & 0 deletions ormat_apn_token.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # 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