File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
plugins/push/api/send/platforms Expand file tree Collapse file tree 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 {
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 } ) ) ;
You can’t perform that action at this time.
0 commit comments