2017-02-14 2 views
0

Nodejs 서버에서 알림을 보내려하지만, 해결 방법을 모르는 오류가 발생합니다. 누군가 나를 도울 수 있습니까? 나는 인터넷이 가능한 솔루션을 발견 ->URLFcm 알림 android/IOS nodejs

이 방화벽이 443 포트에 연결할 수있는 경우 nodejs

var FCM = require('fcm-push'); 

function sendNotification(){ 

var serverKey = 'AAAAJnK3Ing:AP-(more caracters)AwAlBL_CvXIkFM2UufYZHYkvhC7FP3Tu16mlI'; 
var fcm = new FCM(serverKey); 

var message = { 
    to: 'd2b2v(more caracters token)DUmAXqU-uHptJJLRPXukl', 
    /*data: { 
     your_custom_data_key: 'your_custom_data_value' 
    },*/ 
    notification: { 
     title: 'notification', 
     body: 'This is a notification from node' 
    } 
}; 

//callback style 
fcm.send(message, function(err, response){ 
    if (err) { 
     console.log("****************************************************") 
     console.log(message) 
     console.log("Something has gone wrong!"); 
    } else { 
     console.log("Successfully sent with response: ", response); 
    } 
}); 

//promise style 
fcm.send(message) 
    .then(function(response){ 
     console.log("Successfully sent with response: ", response); 
    }) 
    .catch(function(err){ 
     console.log("----------------------------------------------------") 
     console.log("Something has gone wrong!"); 
     console.error(err); 
    }) 

} 

module.exports = { 
    sendNotification 
} 

I am getting this error

답변

0

시도에 내 코드를 확인하는 것입니다. 연결을 만들 수없는 것 같습니다.

+0

예, 열어보고 듣고 있습니다. –