做这个教程,我不想device.js
只在里面放一行:module.exports = "<a1 ..
如何将此设备 ID 放在我的主脚本中,并将其传递给apnagent
对象?试过这个,但我想这就是连接没有建立的原因。
也许而不是module.exports = "<388 ..
我需要类似的东西agent.set('something', and here the device ID);
?
var pfx = '/var/lib/openshift/555dd1415973ca1660000085/app-root/runtime/repo/pfx.p12';
module.exports = "<38873D3B 0D61A965 C1323D6C 0A9F2866 D1BB50A3 64F199E5 483862A6 7F02049C>"; // <----- THIS HERE
var apnagent = require('apnagent')
var agent = module.exports = new apnagent.Agent();
agent.set('pfx file', pfx);
// our credentials were for development
agent.enable('sandbox');
console.log('LOG1');
console.log(agent);
agent.connect(function (err) {
console.log('LOG2');
// gracefully handle auth problems
if (err && err.name === 'GatewayAuthorizationError') {
console.log('Authentication Error: %s', err.message);
process.exit(1);
}
// handle any other err (not likely)
else if (err) {
throw err;
}
// it worked!
var env = agent.enabled('sandbox')
? 'sandbox'
: 'production';
console.log('apnagent [%s] gateway connected', env);
});