Я следовал руководству по реализации уведомления наблюдателя.
exports.observeFollowing = functions.database.ref('/following/{uid}/{followingId}').onCreate((snapshot, context) => {
var uid = context.params.uid;
var followingId = context.params.followingId;
console.log('User: ' + uid + ' is following: ' + followingId);
return admin.database().ref('/users/' + followingId).once('value', snapshot => {
var userWeAreFollowing = snapshot.val();
return admin.database().ref('/users/' + uid).once('value', snapshot => {
var userDoingTheFollowing = snapshot.val();
var payload = {
notification: {
title: "You now have a new follower",
body: userDoingTheFollowing.username + "is now following you",
sound: 'default'
}
}
admin.messaging().sendToDevice(userWeAreFollowing.fcmToken, payload)
.then((response) => {
console.log('Successfully sent message:', response);
return response;
}).catch(function(error) => {
console.log('Error sending message:', error);
});
})
})
})
Однако, когда я пытался запустить firebase deploy - только функции: наблюдаем, я получаю следующую ошибку:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Я пыталсяискать ответы в Stackoverflow, но ни один из ответов не работает.