Skip to content

Commit

Permalink
Merge pull request Countly#5439 from Countly/SER-1714-new-fcm-api-doe…
Browse files Browse the repository at this point in the history
…snt-allow-objects-inside-data-property

[push] objects are not allowed for the properties inside "data" key of the payload in new FCM API
  • Loading branch information
coskunaydinoglu authored Jul 30, 2024
2 parents f0ff190 + eee9450 commit 468460f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugins/push/api/send/platforms/a.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ class FCM extends Splitter {
};
if (!this.legacyApi) {
const tokens = pushes.map(p => p.t);

// new fcm api doesn't allow objects or arrays inside "data" property
if (content.data && typeof content.data === "object") {
for (let prop in content.data) {
if (content.data[prop] && typeof content.data[prop] === "object") {
content.data[prop] = JSON.stringify(content.data[prop]);
}
}
}

const messages = tokens.map(token => ({
token,
...content,
Expand Down

0 comments on commit 468460f

Please sign in to comment.