File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,25 +9,34 @@ const platform = {
99
1010const generatePayload = async function ( title , message ) {
1111
12- return {
13- notifications : [
14- {
15- tokens : await getDevicesByPlatform ( platform . android ) ,
16- platform : platform . android ,
17- message : message ,
18- title : title
19- } ,
20- {
21- tokens : await getDevicesByPlatform ( platform . ios ) ,
22- platform : platform . ios ,
23- message : message ,
24- 'alert' : {
25- 'title' : title ,
26- 'body' : message ,
27- }
12+ let notifications = [ ] ;
13+
14+ let iosTokens = await getDevicesByPlatform ( platform . ios ) ,
15+ androidTokens = await getDevicesByPlatform ( platform . android ) ;
16+
17+ if ( androidTokens . length > 0 ) {
18+ notifications . push ( {
19+ tokens : androidTokens ,
20+ platform : platform . android ,
21+ message : message ,
22+ title : title
23+ } ) ;
24+ }
25+
26+ if ( iosTokens . length > 0 ) {
27+ notifications . push ( {
28+ tokens : iosTokens ,
29+ platform : platform . ios ,
30+ topic : 'com.hackfsu.ios' ,
31+ message : message ,
32+ 'alert' : {
33+ 'title' : title ,
34+ 'body' : message ,
2835 }
29- ]
30- } ;
36+ } )
37+ }
38+
39+ return { notifications } ;
3140} ;
3241
3342module . exports = async function ( req , res ) {
You can’t perform that action at this time.
0 commit comments