Skip to content

Commit 3c9fb6e

Browse files
Merge pull request #5598 from Countly/SER-1963-push-buttons-and-badges-are-not-working
[push] fixed migration related push payload issues
2 parents 3ec1a69 + eab120e commit 3c9fb6e

File tree

1 file changed

+16
-3
lines changed
  • plugins/push/api/send/platforms

1 file changed

+16
-3
lines changed

plugins/push/api/send/platforms/a.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,24 @@ class FCM extends Splitter {
125125
const one = Math.ceil(bytes / pushes.length);
126126
let content = this.template(pushes[0].m).compile(pushes[0]);
127127

128+
// new fcm api doesn't allow objects or arrays inside "data" property
129+
if (content.data && typeof content.data === "object") {
130+
for (let prop in content.data) {
131+
switch (typeof content.data[prop]) {
132+
case "object":
133+
content.data[prop] = JSON.stringify(content.data[prop]);
134+
break;
135+
case "number":
136+
content.data[prop] = String(content.data[prop]);
137+
break;
138+
}
139+
}
140+
}
141+
128142
const errors = {};
129143
/**
130144
* Get an error for given code & message, create it if it doesn't exist yet
131-
*
145+
*
132146
* @param {number} code error code
133147
* @param {string} message error message
134148
* @returns {SendError} error instance
@@ -141,8 +155,7 @@ class FCM extends Splitter {
141155
return errors[err];
142156
};
143157

144-
const tokens = pushes.map(p => p.t);
145-
const messages = tokens.map(token => ({
158+
const messages = pushes.map(p => p.t).map((token) => ({
146159
token,
147160
...content,
148161
}));

0 commit comments

Comments
 (0)