我想将以下行移至我的development.rb
和production.rb
,因此我不需要在生产和开发中更改证书路径(减少合并冲突)。现在它们在我的控制器中定义,但将它们移动到我的config
文件夹却什么也没做。我这样做了吗?
在development.rb
APN = Houston::Client.development
APN.certificate = File.read("/path/to/apple_push_notification.pem")
然后在我的控制器中
notification = Houston::Notification.new(device: phone.device_token)
notification.alert = "Push me!"
notification.sound = "default"
notification.badge = 1
APN.push(notification)
答案 0 :(得分:0)
您不需要在开发和生产中移动这些文件
您甚至可以通过检查环境
放入控制器来完成此操作if Rails.env.development?
APN = Houston::Client.development
APN.certificate = File.read("/path/to/apple_push_notification.pem")
elsif Rails.env.production?
APN = Houston::Client.production ## ALL you have to change this to production
APN.certificate = File.read("/path/to/apple_push_notification.pem")
end