开发者

APN Device Token Encoding when using ColdFusion com.notnoop.apns.SimpleApnsNotification

开发者 https://www.devze.com 2023-03-16 06:15 出处:网络
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

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.

0

精彩评论

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