Open gotmikhail opened 6 years ago
The FCP server API reference states:
Values in string types are recommended. You have to convert values in objects
or other non-string data types (e.g., integers or booleans) to string.
@shasd can you also please take a look?
yeah Im also curious aboyt this. Im facing the problem how to send my data payload from server to the client. Any suggestions on how to stringify/parse the payload automatically so i dont have to remember that data payload can be set as
const payload = {
data: {
body: 1
}
};
and it will be stringified or somthing.
rather than always remeber to make this as string ?
const payload = {
data: {
body: '1'
}
};
Perhaps look into TypeScript? Our type definitions enforce this correctly:
[key: string]: string;
string;
Any changes ? how to add JSON object within data payload ?
@redward You'll have to stringify the object.
const payload = {
data: {
foo: JSON.stringify({foo: "bar"}),
body: "Notification Body",
...
}
};
Operating System version: CentOS Firebase SDK version: 5.4.1 Firebase Product: Cloud Messaging
https://github.com/firebase/firebase-admin-node/blob/fc45c4f5da404e21934cbd9f5a4e7116cb744f0a/src/messaging/messaging.ts#L715
Is there any particular reason why we're restricting the values of the
key:value
pairs indata
to juststring
s?If calling
https://fcm.googleapis.com/fcm/send
directly, you can includeobjects
withindata
.