gpt4 book ai didi

ios - 使用 Rpush Gem Ruby on Rails 向 App 发送通知

转载 作者:行者123 更新时间:2023-11-29 02:53:47 25 4
gpt4 key购买 nike

我正在尝试使用 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 = "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!

这会将通知保存到数据库中。我想知道如何发送此通知。

最佳答案

使用 rpush 这应该可以实际发送您的推送消息。可能是您的证书设置不正确,或者推送 token 不正确,或者您可能尚未启动 rpush。你在你的堆栈中的某个地方调用 Rpush.embed 吗?我把它放在 config.ru 中

关于ios - 使用 Rpush Gem Ruby on Rails 向 App 发送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24161522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com