I send notification to my mobile and use
firebase.messaging().requestPermissions();
firebase.messaging().getToken()
.then((token) => {
console.log('Device FCM Token: ', token);
});
firebase.messaging().onMessage((notif) => {
console.log('message', notif)
}
);
and this code work but i not see notification like this
https://www.google.com/search?q=notification+android&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjX5rTL3o7YAhXKuRQKHTlVBoIQ_AUICigB&biw=1680&bih=864#imgrc=A1TdJz17QZOjmM:
What am I doing wrong?
Hello - How are you sending them? Whats the data payload?
@Ehesp Hello. This my code for sending
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.touch = functions.database.ref('messages/{gid}/message/{messageid}').onWrite(
event => {
admin.database().ref('userTokens/' + users[el]).once('value')
.then(sn => {
snap.val() !== null && snap.val().hasOwnProperty(users[el]) && snap.val()[users[el]].value === 'unread'
?
admin.database().ref('forMobileShow/' + users[el] + '/' + event.params.gid)
.update({countUnreadMessages: event.params.messageid - snap.val()[users[el]].lastKeyDb})
.then(() => {
admin.messaging().sendToDevice(sn.val().token, {
notification: {
title: 'You have a new follower!',
body: ' is now following you.'
}
})
})
: null
})
})
})
})
}
And this i have recieved
Your notification is missing the following properties for it to display in the OS:
sound: 'default',
color: '#84B2D9',
icon: 'ic_notification',
click_action: 'OPEN_MAIN_ACTIVITY',
We will be improving our FCM documentation as part of our next major release. In the meantime please refer to the official firebase documentation to learn more about the available FCM options.
Most helpful comment
Your notification is missing the following properties for it to display in the OS:
We will be improving our FCM documentation as part of our next major release. In the meantime please refer to the official firebase documentation to learn more about the available FCM options.