Ale*_*hin 4 git heroku pem node.js
我有一个git-tracked repo,我正在设置它与APN合作进行IOS推送通知.我正在尝试以与PushNotificationSample类似的方式实现npm模块node-apn
在这段代码中,有
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
}
Run Code Online (Sandbox Code Playgroud)
但是,我是如何在不将它们提交给Github的情况下引用我的.pem文件的?
目前,我正在部署到Heroku.
通过Heroku的(环境)配置变量执行此操作.
如果您正在使用node-apn或类似的东西,您应该能够传递证书和密钥内容而不是路径.使用ENV vars传递关键内容,如Heroku所推荐.
cert: process.env.APN_CERT,
key: process.env.APN_KEY,
passphrase: process.env.APN_PASSPHRASE,
Run Code Online (Sandbox Code Playgroud)
由于您无法在Web界面中为app config设置多行值,因此您必须使用命令行进行设置APN_CERT和APN_KEY:
$ heroku config:set APN_CERT="-----BEGIN CERTIFICATE-----
> MIIDOjCCAiICCQCZTWzQNz6sqTANBgkqhkiG9w0BAQsFADBfMQswCQYDVQQGEwJB
> VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
...
Run Code Online (Sandbox Code Playgroud)