Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const notification_id = event.params.notification_id;
- console.log('Temos uma notificação para enviar para: ', receiver_id);
- if(!event.data.val())
- {
- return.console.log('A notificação foi excluída do banco de dados: ', notification_id);
- }
- const deviceToken = admin.database().ref(`/usuarios/${receiver_id}/device_token`).once('value');
- return deviceToken.then(result =>
- {
- const token_id = result.val();
- const payload =
- {
- notification:
- {
- title: "Friends Request",
- body: "Voce tem uma requisição de um novo amigo",
- icon: "default"
- }
- };
- return admin.messaging().sendToDevice(token_id, payload)
- .then(response =>
- {
- console.log('Este é o recurso de notificação.');
- });
- });
- });
Add Comment
Please, Sign In to add comment