@@ -78,70 +78,9 @@ export class SNSPushAdapter extends PushAdapter {
78
78
} ;
79
79
}
80
80
81
- // FIXME - pull out of GCM as static
82
- generateGCMPayload ( coreData , pushId , timeStamp , expirationTime ) {
83
-
84
- const GCMTimeToLiveMax = 4 * 7 * 24 * 60 * 60 ; // GCM allows a max of 4 weeks
85
-
86
- let payloadData = {
87
- 'time' : new Date ( timeStamp ) . toISOString ( ) ,
88
- 'push_id' : pushId ,
89
- 'data' : JSON . stringify ( coreData )
90
- }
91
- let payload = {
92
- priority : 'normal' ,
93
- data : payloadData
94
- } ;
95
- if ( expirationTime ) {
96
- // The timeStamp and expiration is in milliseconds but gcm requires second
97
- let timeToLive = Math . floor ( ( expirationTime - timeStamp ) / 1000 ) ;
98
- if ( timeToLive < 0 ) {
99
- timeToLive = 0 ;
100
- }
101
- if ( timeToLive >= GCMTimeToLiveMax ) {
102
- timeToLive = GCMTimeToLiveMax ;
103
- }
104
- payload . timeToLive = timeToLive ;
105
- }
106
- return payload ;
107
- }
108
-
109
81
// Generate proper json for GCM message
110
82
generateAndroidPayload ( data ) {
111
- let pushId = cryptoUtils . newObjectId ( ) ;
112
- let timeStamp = Date . now ( ) ;
113
- let expirationTime ;
114
- // We handle the expiration_time convertion in push.js, so expiration_time is a valid date
115
- // in Unix epoch time in milliseconds here
116
- if ( data [ 'expiration_time' ] ) {
117
- expirationTime = data [ 'expiration_time' ] ;
118
- }
119
-
120
- // var payload = this.generateGCMPayload(data.data, pushId, timestamp, expirationTime);
121
-
122
- const GCMTimeToLiveMax = 4 * 7 * 24 * 60 * 60 ; // GCM allows a max of 4 weeks
123
-
124
- let payloadData = {
125
- 'time' : new Date ( timeStamp ) . toISOString ( ) ,
126
- 'push_id' : pushId ,
127
- 'data' : JSON . stringify ( data . data )
128
- }
129
- let payload = {
130
- priority : 'normal' ,
131
- data : payloadData
132
- } ;
133
-
134
- if ( expirationTime ) {
135
- // The timeStamp and expiration is in milliseconds but gcm requires second
136
- let timeToLive = Math . floor ( ( expirationTime - timeStamp ) / 1000 ) ;
137
- if ( timeToLive < 0 ) {
138
- timeToLive = 0 ;
139
- }
140
- if ( timeToLive >= GCMTimeToLiveMax ) {
141
- timeToLive = GCMTimeToLiveMax ;
142
- }
143
- payload . timeToLive = timeToLive ;
144
- }
83
+ var payload = GCM . generateGCMPayload ( data ) ;
145
84
146
85
// SNS is verify sensitive to the body being JSON stringified but not GCM key.
147
86
return {
0 commit comments