File tree 1 file changed +27
-18
lines changed
1 file changed +27
-18
lines changed Original file line number Diff line number Diff line change @@ -9,25 +9,34 @@ const platform = {
9
9
10
10
const generatePayload = async function ( title , message ) {
11
11
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 ,
28
35
}
29
- ]
30
- } ;
36
+ } )
37
+ }
38
+
39
+ return { notifications } ;
31
40
} ;
32
41
33
42
module . exports = async function ( req , res ) {
You can’t perform that action at this time.
0 commit comments