错误 - 为推送通知建立连接时凭据不足

时间:2014-10-18 23:36:04

标签: ios node.js apple-push-notifications engineyard apnagent

我正在尝试在我的ios应用程序和用户node.js中发送推送通知。所以我从链接中获取教程:https://blog.engineyard.com/2013/developing-ios-push-notifications-nodejs

在本教程中,他们将私钥的密码保留为空。但是我为我的私钥设置了密码,我不知道如何在编码中包含我的密码。我知道有很多方面的答案。但是没有任何作品。我试过了:

.set('cert file', join(__dirname, '../_cert/apn-dev-cert.pem'))
.set('key file', join(__dirname, '../_cert/apn-dev-key.pem'))
//or this works too:
// .set('pfx file', join(__dirname, '../_cert/Certificates.p12'))
// .set('passphrase', 'your passphrase')
.enable('sandbox')



agent.on('message:error', function (err, msg) {
  connect.log('error1');
  switch (err.name) {

// This error occurs when Apple reports an issue parsing the message.
case 'GatewayNotificationError':
  console.log('[message:error] GatewayNotificationError: %s', err.message);


  // The err.code is the number that Apple reports.
  // Example: 8 means the token supplied is invalid or not subscribed
  // to notifications for your application.
  if (err.code === 8) {        
    console.log('    > %s', msg.device().toString());
    // In production you should flag this token as invalid and not
    // send any futher messages to it until you confirm validity
  }

  break;

// This happens when apnagent has a problem encoding the message for transfer
case 'SerializationError':
  console.log('[message:error] SerializationError: %s', err.message);

  break;

// unlikely, but could occur if trying to send over a dead socket
default:
  console.log('[message:error] other error: %s', err.message);      
  break;
  }
});

/*!
 * Make the connection
 */


agent.connect(function (err) {
  // 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) {
    console.log('error1');
    throw err;
  }

  // it worked!
  var env = agent.enabled('sandbox')
    ? 'sandbox'
    : 'production';
  console.log('apnagent [%s] gateway connected', env);
});

我还尝试连接证书和密钥,并将其用作单个文件,没有任何作用。

0 个答案:

没有答案