2014-10-14 5 views
1

я после урока с этого сайта:Push уведомление отсутствует сообщения

https://blog.engineyard.com/2013/developing-ios-push-notifications-nodejs

доставить уведомление толчок в моем приложении.

Я до сих пор успешно создал сертификат и другие файлы. На стороне сервера я не смог пройти шаг «Создание соединения».

Я могу получить токен своего устройства в консоли во время запуска приложения. В учебном пособии сказано, что после подключения к терминалу консоль должна выдавать вывод как «подключенный шлюз».

Но я не получаю это сообщение. В худшем случае я тоже не получаю сообщение об ошибке :(Интересно, что пошло не так. Несмотря на то, что у меня возникли некоторые ошибки при первом подключении, как к недостаточным учетным данным, проверка подлинности с помощью mac, я решил их. правильное сообщение. Может кто-то пожалуйста, помогите?

Я также добавить свой терминал здесь консоль

SIVAs-MacBook-Air:~ AAA$ cd Desktop/ 
SIVAs-MacBook-Air:Desktop AAA$ cd poservices/ 
SIVAs-MacBook-Air:poservices AAA$ node agent/_header.js 
SIVAs-MacBook-Air:poservices AAA$ node agent/_header.js 
SIVAs-MacBook-Air:poservices AAA$` 


var join = require('path').join 
    , pfx = join(__dirname, '../_certs/pfx.p12'); 

/*! 
* Create a new gateway agent 
*/ 

var apnagent = require('apnagent') 
    , agent = module.exports = new apnagent.Agent(); 


/*! 
* Configure agent 
*/ 

agent 
    .set('pfx file', pfx) 
    .enable('sandbox'); 

/*! 
* Error Mitigation 
*/ 

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

Вам нужно добавить

agent.set('passphrase', '<YOUR_PASSWORD>'); 

после

agent.set('pfx file', pfx).enable('sandbox');