APN Device Token Encoding when using ColdFusion com.notnoop.apns.SimpleApnsNotification
I'm developing an iOS app dealing with push notifications. Our push notification server is written in ColdFusion and is using com.notnoop.apns.SimpleApnsNotification
to send the notifications. In the app, I grab the device token (NSData
) and Base64 encode it before sending it off to the server. However, while the SimpleApnsNotification
api is expecting a String 开发者_开发技巧for the token, it doesn't appear to want a Base64 encoded String.
Do you know what encoding SimpleApnsNotification
is expecting for the device token?
You've got to hex encode it. Try making a Category on NSData with this method in it (this worked great for me):
- (NSString*) hexEncode {
NSString *deviceToken = [[self description] stringByReplacingOccurrencesOfString: @"<" withString: @""];
deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @">" withString: @""] ;
deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @" " withString: @""];
return deviceToken;
}
Give that a try and see if it works for you, too.
精彩评论