File tree 1 file changed +16
-3
lines changed
plugins/push/api/send/platforms
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -125,10 +125,24 @@ class FCM extends Splitter {
125
125
const one = Math . ceil ( bytes / pushes . length ) ;
126
126
let content = this . template ( pushes [ 0 ] . m ) . compile ( pushes [ 0 ] ) ;
127
127
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
+
128
142
const errors = { } ;
129
143
/**
130
144
* Get an error for given code & message, create it if it doesn't exist yet
131
- *
145
+ *
132
146
* @param {number } code error code
133
147
* @param {string } message error message
134
148
* @returns {SendError } error instance
@@ -141,8 +155,7 @@ class FCM extends Splitter {
141
155
return errors [ err ] ;
142
156
} ;
143
157
144
- const tokens = pushes . map ( p => p . t ) ;
145
- const messages = tokens . map ( token => ( {
158
+ const messages = pushes . map ( p => p . t ) . map ( ( token ) => ( {
146
159
token,
147
160
...content ,
148
161
} ) ) ;
You can’t perform that action at this time.
0 commit comments