iPhone 推送通知在 Rails 应用程序中不起作用 - apn_sender

发布于 2024-11-15 00:50:08 字数 1105 浏览 3 评论 0 原文

我已经使用本教程作为指导,设置了 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱要勇敢去追 2024-11-22 00:50:08

设法解决了这个问题 - 问题似乎出在我使用的令牌格式上。

改成这样的格式:

# (regexp)
/(\w{8}\s){7}(\w{8})/

# randomly generated example string
f4134ff5 ec6504c2 a803da24 fb79cbcd 5243b00d d7fa625f 54c6b4ea 05768cf4

Managed to fix this one - the problem seemed to be with the token format I was using.

Changed to this format:

# (regexp)
/(\w{8}\s){7}(\w{8})/

# randomly generated example string
f4134ff5 ec6504c2 a803da24 fb79cbcd 5243b00d d7fa625f 54c6b4ea 05768cf4
°如果伤别离去 2024-11-22 00:50:08

APN::Feedback:当前未在 2196 上建立与 Feedback.sandbox.push.apple.com 的连接,

您需要调用 .data 方法来启动连接。

feedback_data = APN::Feedback.new().data

每当您使用无效令牌时,APNS 都会断开您的连接,这可能会导致问题,所以我想这就是您的正则表达式有意义的原因。这是我的正则表达式,用于在删除空格后进行检查。即使没有空格,令牌仍然被接受。

[a-zA-Z0-9]{64}

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.

feedback_data = APN::Feedback.new().data

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.

[a-zA-Z0-9]{64}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文