Flutter FCM:在数据消息中发送documentSnapshot
Flutter FCM: send documentSnapshot in data message
我对编程还很陌生,所以我希望得到你的好意。
是否可以在 FCM 数据消息有效负载中发送字符串以外的其他类型,例如 bool、List 甚至 documentSnapshot?
如果您查看 reference documentation for message.data
,它被定义为:
data
map (key: string, value: string)
Input only. Arbitrary key/value payload. The key should not be a reserved word ("from"
, "message_type"
, or any word starting with "google"
or "gcm"
).
An object containing a list of "key": value
pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }
.
所以它是一个键值对的平面列表,其中键和值都是字符串。如果你当然可以在该值中存储任何你想要的数据,只要你 encode/decode 它是一个字符串。
我对编程还很陌生,所以我希望得到你的好意。 是否可以在 FCM 数据消息有效负载中发送字符串以外的其他类型,例如 bool、List 甚至 documentSnapshot?
如果您查看 reference documentation for message.data
,它被定义为:
data
map (key: string, value: string)
Input only. Arbitrary key/value payload. The key should not be a reserved word (
"from"
,"message_type"
, or any word starting with"google"
or"gcm"
).An object containing a list of
"key": value
pairs. Example:{ "name": "wrench", "mass": "1.3kg", "count": "3" }
.
所以它是一个键值对的平面列表,其中键和值都是字符串。如果你当然可以在该值中存储任何你想要的数据,只要你 encode/decode 它是一个字符串。