我已经使用本教程作为指导,设置了 Rails 应用程序以将推送通知发送到我的 iPhone 应用程序:
http://blog.thefrontiergroup.com.au/2011/05/sending-apple-push-notifications-in-rails-with-redis-and-apn_sender/
一切似乎都是运行良好 - 但当我尝试在控制台中创建新通知时
APN.notify(my_token, :alert => "Test message", :badge =>; 4、:sound => true)
它返回的只是一个空数组! <代码> # => []
当我检查反馈时
feedback = APN::Feedback.new
,我收到消息:
APN::Feedback: Connection not currently established to feedback.sandbox.push.apple.com on 2196
我已连接到 redis OK,它似乎正在记录大量数据:
[13058] 08 Jun 16:42:03 - DB 0: 2 keys (0 volatile) in 4 slots HT.
[13058] 08 Jun 16:42:03 - 0 clients connected (0 slaves), 922944 bytes in use
[13058] 08 Jun 16:42:08 - DB 0: 2 keys (0 volatile) in 4 slots HT.
但是(据我所知)我没有连接到苹果服务器。
这是在我的 OSX 10.6 开发环境上。
红宝石 1.9.2
Rails 3.1.0.rc1
有人能帮我解决这个问题吗?
iPhone 通知令牌应采用什么格式? Base64 解码?
I've set up my rails app to send push notifications to my iphone app using this tutorial as my guide:
http://blog.thefrontiergroup.com.au/2011/05/sending-apple-push-notifications-in-rails-with-redis-and-apn_sender/
Everything seems to be running fine - but when I try to create a new notification in the console
APN.notify(my_token, :alert => "Test message", :badge => 4, :sound => true)
all it returns is an empty array! # => []
When I check for feedback
feedback = APN::Feedback.new
I get the message:
APN::Feedback: Connection not currently established to feedback.sandbox.push.apple.com on 2196
I'm connected to redis OK, it seems to be logging lots of data:
[13058] 08 Jun 16:42:03 - DB 0: 2 keys (0 volatile) in 4 slots HT.
[13058] 08 Jun 16:42:03 - 0 clients connected (0 slaves), 922944 bytes in use
[13058] 08 Jun 16:42:08 - DB 0: 2 keys (0 volatile) in 4 slots HT.
But (as far as I'm aware) I'm not connected to the apple server.
This is on my OSX 10.6 development environment.
Ruby 1.9.2
Rails 3.1.0.rc1
Can anybody help me troubleshoot this?
What format should the iPhone notification token be in? Base64 decoded?
发布评论
评论(2)
设法解决了这个问题 - 问题似乎出在我使用的令牌格式上。
改成这样的格式:
Managed to fix this one - the problem seemed to be with the token format I was using.
Changed to this format:
APN::Feedback:当前未在 2196 上建立与 Feedback.sandbox.push.apple.com 的连接,
您需要调用 .data 方法来启动连接。
每当您使用无效令牌时,APNS 都会断开您的连接,这可能会导致问题,所以我想这就是您的正则表达式有意义的原因。这是我的正则表达式,用于在删除空格后进行检查。即使没有空格,令牌仍然被接受。
APN::Feedback: Connection not currently established to feedback.sandbox.push.apple.com on 2196
you need to call the .data method to start the connect.
and whenever you use a invalid toke, APNS disconnects you which might cause problems so I guess that is why your Regex makes sense. here is my regex for checking after removing spaces. Even without spaces, tokens still are accepted.