我正在使用Firebase Cloud函数通过Node js和我的应用程序在Swift上进行通知
这是我的有效载荷
var payload = {
notification: {
title: (goOfflineTimePeriod,"Inactive for minutes you are now offline"),
body: "Time period for inactive log off can be changed in your settings"
尽管我的通知我的通知仅显示为; “您处于离线状态的几分钟内处于非活动状态”,“可以在您的设置中更改非活动注销的时间段”
所以变量; goOfflineTimePeriod没有显示在通知中
我只是Node JS的新手,是否有一个原因为什么通知中未显示“ goOfflineTimePeriod”?
这是我的全节点js功能代码;
exports.goOfflineAlert = functions.firestore
.document('/goneOffline/{uid}')
.onCreate((snap, context) => {
var db = admin.firestore();
var uid = context.params.uid;
const newValue = snap.data();
const goOfflineTimePeriod = newValue.goneOffline;
console.log('uid is',uid)
var cityRef = db.collection('Users').doc(uid);
var getDoc = cityRef.get()
.then(doc => {
if (!doc.exists) {
return console.log('No such document!');
} else {
const newValue = doc.data();
const age = newValue.Age;
const name = newValue['Display Name'];
const fcmToken = newValue.fcmToken;
const goOfflineTimePeriod = newValue.goOfflineTimePeriod;
console.log('Document data:', doc.data(),age,fcmToken,name,goOfflineTimePeriod);
var payload = {
notification: {
title: (goOfflineTimePeriod,"Inactive for minutes you are now offline"),
body: "Time period for inactive log off can be changed in your settings"
}
}
答案 0 :(得分:0)
,
operator不会在JavaScript中连接字符串,但是会返回第二个操作数。相反,您应该使用+
或模板字符串。例如:
title: goOfflineTimePeriod+" Inactive for minutes you are now offline",