开发者

iPhone pushNotification DeviceToken - How to "decrypt"

I've already managed to get the devicetoken from APNs. It's type of NSData. So i want to write this d开发者_开发百科eviectoken into my mysql db. I've already tried to convert it to a string without luck. That was my way:

 NSString *tokenTMP = [[NSString alloc] initWithData:devToken encoding:NSASCIIStringEncoding];

If i have the deviceToken in a readable format. How do i use the token in php to send a request to the apns server?

thanks a lot!


I added the following category to NSData

- (NSString*) stringWithHexBytes 
{
   NSMutableString *stringBuffer = [NSMutableString stringWithCapacity:([self length] * 2)];
   const unsigned char *dataBuffer = [self bytes];

   for (int i = 0; i < [self length]; ++i)
   {
       [stringBuffer appendFormat:@"%02X", (unsigned long)dataBuffer[ i ]];
   }

   return [[stringBuffer retain] autorelease];
}

Then I can just call [devToken stringWithHexBytes]; and send that up to my server and store it as text.

Hope that helps.

chris.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜