最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

获取存储在使用Javascript火力地堡对象的孩子

IT培训 admin 6浏览 0评论

获取存储在使用Javascript火力地堡对象的孩子

我简单的Java对象(从Android设备的设备令牌)存储为文档火力地堡的集合:

public class DeviceToken {
    String tokenID;


    public DeviceToken() {
    }

    public DeviceToken(String tokenID) {
        this.tokenID = tokenID;
    }


    public String getTokenID() {
        return tokenID;
    }

    public void setTokenID(String tokenID) {
        this.tokenID = tokenID;
    }
}

I

我试图获取此对象在javascript以下云功能的字符串的tokenID孩子:

exports.sendDMNotification = functions.firestore.document('/dm_threads/{thread_id}/messages/{message_id}')
    .onCreate((snapshot, context) => {


        const newMessage = snapshot.data();

        const senderName = newMessage.authorName;
        const senderID = newMessage.authorUID;
        const messageText = newMessage.message;
        const recipientName = newMessage.recipientName;
        const recipientID = newMessage.recipientUID;
        const timestamp = newMessage.timestamp;


        let deviceTokenQuery = admin.firestore().collection(`/users/${recipientID}/device_tokens/`);

        return deviceTokenQuery.get().then(querySnapshot => {

            let tokenShapshot = querySnapshot.docs;

            const notificationPromises = tokenShapshot.map(token => {


                let token_id = token['tokenID'];

                console.log(token_id);
                console.log(token)
                console.log(JSON.stringify(token));


                const payload = {
                    notification: {
                        title: senderName,
                        body: messageText,
                        icon: "default"
                    }
                };


                return admin.messaging().sendToDevice(token_id, payload)

            });

            return Promise.all(notificationPromises);

        });

    });

第一个日志语句返回不确定的,第二个返回的翻译:和什么似乎是一串元数据的引用文件,但没有一个对象的属性的,因为我使用它的第三回报。我该如何找回刚才我获取该对象的文件是tokenID孩子?

回答如下:

既然你呼吁qazxsw POI qazxsw POI,我想传递给map回调每个项目的文件。在这种情况下,你仍然需要调用querySnapshot.docs拿到的文件的数据:

map

获取存储在使用Javascript火力地堡对象的孩子

我简单的Java对象(从Android设备的设备令牌)存储为文档火力地堡的集合:

public class DeviceToken {
    String tokenID;


    public DeviceToken() {
    }

    public DeviceToken(String tokenID) {
        this.tokenID = tokenID;
    }


    public String getTokenID() {
        return tokenID;
    }

    public void setTokenID(String tokenID) {
        this.tokenID = tokenID;
    }
}

I

我试图获取此对象在javascript以下云功能的字符串的tokenID孩子:

exports.sendDMNotification = functions.firestore.document('/dm_threads/{thread_id}/messages/{message_id}')
    .onCreate((snapshot, context) => {


        const newMessage = snapshot.data();

        const senderName = newMessage.authorName;
        const senderID = newMessage.authorUID;
        const messageText = newMessage.message;
        const recipientName = newMessage.recipientName;
        const recipientID = newMessage.recipientUID;
        const timestamp = newMessage.timestamp;


        let deviceTokenQuery = admin.firestore().collection(`/users/${recipientID}/device_tokens/`);

        return deviceTokenQuery.get().then(querySnapshot => {

            let tokenShapshot = querySnapshot.docs;

            const notificationPromises = tokenShapshot.map(token => {


                let token_id = token['tokenID'];

                console.log(token_id);
                console.log(token)
                console.log(JSON.stringify(token));


                const payload = {
                    notification: {
                        title: senderName,
                        body: messageText,
                        icon: "default"
                    }
                };


                return admin.messaging().sendToDevice(token_id, payload)

            });

            return Promise.all(notificationPromises);

        });

    });

第一个日志语句返回不确定的,第二个返回的翻译:和什么似乎是一串元数据的引用文件,但没有一个对象的属性的,因为我使用它的第三回报。我该如何找回刚才我获取该对象的文件是tokenID孩子?

回答如下:

既然你呼吁qazxsw POI qazxsw POI,我想传递给map回调每个项目的文件。在这种情况下,你仍然需要调用querySnapshot.docs拿到的文件的数据:

map
发布评论

评论列表 (0)

  1. 暂无评论