我有一个git-tracked repo,我正在设置它与APN合作进行IOS推送通知。我正在尝试以与node-apn
类似的方式实现npm模块PushNotificationSample在此代码中,有
var options = {
gateway: 'gateway.sandbox.push.apple.com', // this URL is different for Apple's Production Servers and changes when you go to production
errorCallback: callback,
cert: 'your-cert.pem', // ** NEED TO SET TO YOURS - see this tutorial - http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
key: 'your-key.pem', // ** NEED TO SET TO YOURS
passphrase: 'your-pw', // ** NEED TO SET TO YOURS
port: 2195,
enhanced: true,
cacheLength: 100
}
但是,我是如何在不将它们提交给Github的情况下引用我的.pem文件的?
目前,我正在部署到Heroku。
答案 0 :(得分:7)
通过Heroku的(环境)配置变量执行此操作。
如果你正在使用node-apn或类似的东西,你应该能够pass in the certificate and key content instead of a path。使用ENV vars传递关键内容,如recommended by Heroku。
cert: process.env.APN_CERT,
key: process.env.APN_KEY,
passphrase: process.env.APN_PASSPHRASE,
由于您无法在Web界面中为app config设置多行值,因此您必须使用命令行设置APN_CERT
和APN_KEY
:
$ heroku config:set APN_CERT="-----BEGIN CERTIFICATE-----
> MIIDOjCCAiICCQCZTWzQNz6sqTANBgkqhkiG9w0BAQsFADBfMQswCQYDVQQGEwJB
> VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
...