gpt4 book ai didi

android - 错误 : "data must only contain string values" firebase cloud messaging

转载 作者:行者123 更新时间:2023-12-04 01:35:26 27 4
gpt4 key购买 nike

我正在尝试通过 FCM(Firebase 云消息传递)将一些数据从我的 node.js 服务器发送到 android 客户端。我收到以下错误:发送时“数据只能包含字符串值”。我的数据包含 2 个 JSONObjects。我必须将它们转换为字符串还是去这里的方法是什么?谢谢。

var message = {
notification:{
"title": "Alert!",
"body": position[0] + " has left Area: " + activeGeofences[i][1].name
},
data:{
Geofence: activeGeofences[i][1],
Position: position[1]
},
token: activeGeofences[i][0]
};

最佳答案

要将任何 JSON 对象转换为字符串,您可以使用 JSON.stringify() .在接收方,您可以使用 JSON.parse() (或您的平台的等价物)将字符串解析回树结构。

关于android - 错误 : "data must only contain string values" firebase cloud messaging,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59773069/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com