Установка значка уведомления pu sh для изображения профиля пользователя с функциями Firebase - PullRequest
0 голосов
/ 31 марта 2020

Итак, я пытаюсь установить значок уведомления на изображение профиля пользователя, и вот как я это делаю:

'use strict'

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

exports.sendNotification = functions.database.ref('/Notifications/{receiver_user_id}/{notification_id}')
.onWrite((data, context)=>{

    const receiver_user_id = context.params.receiver_user_id;
    const notification_id = context.params.notification_id;

    console.log('we have a notification to send to:', receiver_user_id);

    if(!data.after.val()){
    console.log('A notification has been delete:', notification_id);
    return null;
    }

    const sender_user_id = admin.database().ref(`/Notifications/${receiver_user_id}/${notification_id}/from`).once('value');
    return sender_user_id.then(fromUserResult =>{
        const from_sender_user_id = fromUserResult.val();
        console.log('you have a notification from:', from_sender_user_id);
        const userQuery = admin.database().ref(`/users/${from_sender_user_id}`).once('value');
        return userQuery.then(userResult=>{
                const senderUsername = userResult.val().username
                console.log('sender username:', senderUsername);
                const senderProfile = userResult.val().profileUrl
                console.log('sender profile picture:', senderProfile);
                const device_token = admin.database().ref(`/users/${receiver_user_id}/device_token`).once('value');
                return device_token.then(result => {
                    const token_id = result.val();
                    const playload = {
                        notification:{
                            from_sender_user_id : from_sender_user_id,
                            title:"Nouveau message",
                            body:`${senderUsername} vous a envoyé un nouveau message`,
                            icon: senderProfile
                        }
                    };
                    return admin.messaging().sendToDevice(token_id,playload).then(response =>{
                        console.log('this was a notification feature.');
                        });
                });
        });



    });


});

значок не показывает изображение профиля. (Пользователь изображение профиля хранится в хранилище Firebase) я впервые работаю с уведомлениями pu sh, поэтому, пожалуйста, помогите!

...