【发布时间】:2017-02-15 08:26:52
【问题描述】:
我知道在这种情况下有很多问题,但我已经尝试了所有解决方案,但我仍然陷入困境。我正在使用 grocer gem 向 APN 服务发送推送通知。我被证书问题困住了。
这是代码
pusher = Grocer.pusher(
certificate: "#{Rails.root}/public/certificate1.pem", # required
passphrase: "", # optional
gateway: "gateway.push.apple.com", # optional; See note below.
port: 2195, # optional
retries: 3 # optional
)
notification = Grocer::Notification.new(
device_token: token,
alert: "#{uname} liked your post",
sound: 'default',
badge: 0
)
pusher.push(notification)
我在一个生产环境中,我在 Heroku 上托管应用程序。 Heroku 日志告诉我这个
OpenSSL::PKey::RSAError (Neither PUB key nor PRIV key: nested asn1 error):
app/controllers/api/v1/feeds_controller.rb:49:in `likeit'
第 49 行是推送通知的行。
我确定我使用的证书是正确的,因为我已经使用它测试了推送通知。此外,在生成 pem 文件时,我已经导出了证书和私钥。
参考:grocer gem
欢迎提出任何建议!
【问题讨论】:
标签: ios ruby-on-rails ssl heroku apple-push-notifications