このtutorialをやって、そして私はそれに1行を入れてdevice.js
を使用したくない:module.exports = "<a1 ..
node.jsでモジュールを使用しないようにするにはどうすればよいですか?
はどのように私のメインのスクリプトでこのデバイス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);
});
おそらく役に立ちます:[Node.js module.exportsの目的は何ですか?どのように使用しますか?](http://stackoverflow.com/questions/5311334/what-is-the-purpose-of-node –