Skip to content

Instantly share code, notes, and snippets.

@crsantos
Last active September 21, 2015 14:10
Show Gist options
  • Save crsantos/e033887c70fe6c17d81a to your computer and use it in GitHub Desktop.
Save crsantos/e033887c70fe6c17d81a to your computer and use it in GitHub Desktop.
APNS deviceToken - NSData* to NSString*
// based on http://stackoverflow.com/a/29075908/468868 answer
const unsigned *tokenBytes = [deviceToken bytes];
NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment