Skip to content

Commit 3338ad9

Browse files
committed
Fix to allow a payload that uses gcm+apns keys
1 parent 1a9cd96 commit 3338ad9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/FCM.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import { randomString } from './PushAdapterUtils';
99
const LOG_PREFIX = 'parse-server-push-adapter FCM';
1010
const FCMRegistrationTokensMax = 500;
1111
const FCMTimeToLiveMax = 4 * 7 * 24 * 60 * 60; // FCM allows a max of 4 weeks
12+
const apnsIntegerDataKeys = [
13+
'badge',
14+
'content-available',
15+
'mutable-content',
16+
'priority',
17+
'expiration_time',
18+
];
1219

1320
export default function FCM(args, pushType) {
1421
if (typeof args !== 'object' || !args.firebaseServiceAccount) {
@@ -242,6 +249,12 @@ function _GCMToFCMPayload(requestData, timeStamp) {
242249
}
243250

244251
if (requestData.hasOwnProperty('data')) {
252+
// FCM gives an error on send if we have apns keys that should have integer values
253+
for (const key of apnsIntegerDataKeys) {
254+
if (requestData.data.hasOwnProperty(key)) {
255+
requestData.data[key] = requestData.data[key].toString();
256+
}
257+
}
245258
androidPayload.android.data = requestData.data;
246259
}
247260

0 commit comments

Comments
 (0)