我想在我的lambda函数中发送推送通知。它在localhost上按预期工作,但是当我将其推送到lambda代码时不起作用。 这是我的代码:
const FCM = require('fcm-node');
let sendNotification = function(regToken) {
let serverKey = 'MY_SERVER_KEY';
let fcm = new FCM(serverKey);
let message = {
to: regToken,
notification: {
title: 'Title of push notification',
body: 'Body of push notification'
}
};
fcm.send(message, function(err, response){
if (err) {
console.log("Something has gone wrong!", err);
} else {
console.log("Successfully sent with response: ", response);
}
});
}
答案 0 :(得分:0)
您需要将函数封装在exports.handler中