apn_notification表中的苹果推送通知sent_at为空
我在 Ruby 中将以下代码与 apn_notfications 一起使用,
device = APN::Device.create(:token => "XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX")
notification = APN::Notification.new
device.id= 'xxxxxxx'
notification.device = device
notification.badge = 5
notification.sound = true
notification.alert = "foobar"
notification.save
但是对于 apn_notifications 表中的某些通知,我得到的 sent_at 为 nil。
请告诉我为什么会发生这种情况以及何时更新表中的 sent_at 字段。
任何帮助将不胜感激。
I use following code with apn_notfications in Ruby
device = APN::Device.create(:token => "XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX")
notification = APN::Notification.new
device.id= 'xxxxxxx'
notification.device = device
notification.badge = 5
notification.sound = true
notification.alert = "foobar"
notification.save
But for some notification in apn_notifications table I got sent_at as nil.
Please tell me why this happen and when sent_at field is updated in Table.
Any help would be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这正是预期的行为。您需要运行 rake apn:notifications:deliver 任务来发送所有未设置的通知。
一旦 rake 任务设法将通知发送到 Apple 服务器,sent_at 字段就会更新。
请务必包含 Rakefile 中的 apn_on_rails_tasks。
This is exactly the expected behaviour. You need to run the rake apn:notifications:deliver task to send all unset notifications.
sent_at field will be updated as soons as the rake task manage to send the notification to the Apple server.
Be sure to include apn_on_rails_tasks from your Rakefile.