本文介绍了使用Rpush Gem Ruby on Rails将通知发送给应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在我的应用中使用Rpush Gem实现推送通知。这是迄今为止我试过的。
if @ push_notification.present?
else
app = Rpush :: Apns :: App.new
app.name =ios_app
app.certificate = File.read(config / apns-dev。 pem)
app.environment =开发#APN环境。
app.password =
app.connections = 1
app.save!
end
n = Rpush :: Apns :: Notification.new
n.app = Rpush :: Apns :: App.find_by_name(ios_app)
n .device_token =会话[:push_notification_token]
n.alert =嗨即时通知!
n.data = {foo::bar}
n.save!
这会将通知保存到数据库中。我想知道如何发送这个通知。使用rpush这应该是实际发送你的推送消息的工作。
解决方案
有可能您的证书设置不正确,或者推送令牌不正确,或者您可能没有启动rpush。你是否在你的堆栈中的某个地方调用Rpush.embed?我已经把它放在config.ru
中
Im trying to implement Push notification in my app using Rpush Gem.This is so far i have tried.
if @push_notification.present?
else
app = Rpush::Apns::App.new
app.name = "ios_app"
app.certificate = File.read("config/apns-dev.pem")
app.environment = "development" # APNs environment.
app.password = ""
app.connections = 1
app.save!
end
n = Rpush::Apns::Notification.new
n.app = Rpush::Apns::App.find_by_name("ios_app")
n.device_token = session[:push_notification_token]
n.alert = "hi im alert!"
n.data = { foo: :bar }
n.save!
this save a notification to the database. I want to know how to send this notification.
解决方案
using rpush this should be working to send your push message actually. there is the possibility that your certificates are not set up right, or that the push token is incorrect, or that perhaps you have not started rpush. Do you call Rpush.embed somewhere in your stack? I have placed this in config.ru
这篇关于使用Rpush Gem Ruby on Rails将通知发送给应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!