File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ func setHeaders(r *http.Request, n *Notification) {
227
227
if n .Priority > 0 {
228
228
r .Header .Set ("apns-priority" , strconv .Itoa (n .Priority ))
229
229
}
230
- if ! n .Expiration .IsZero ( ) {
230
+ if n .Expiration .After ( time . Unix ( 0 , 0 ) ) {
231
231
r .Header .Set ("apns-expiration" , strconv .FormatInt (n .Expiration .Unix (), 10 ))
232
232
}
233
233
if n .PushType != "" {
Original file line number Diff line number Diff line change @@ -245,6 +245,25 @@ func TestHeaders(t *testing.T) {
245
245
assert .NoError (t , err )
246
246
}
247
247
248
+ func TestExpirationHeader (t * testing.T ) {
249
+ n := mockNotification ()
250
+ n .ApnsID = "84DB694F-464F-49BD-960A-D6DB028335C9"
251
+ n .CollapseID = "game1.start.identifier"
252
+ n .Topic = "com.testapp"
253
+ n .Priority = 10
254
+ n .Expiration = time .Unix (0 , 0 )
255
+ server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
256
+ assert .Equal (t , n .ApnsID , r .Header .Get ("apns-id" ))
257
+ assert .Equal (t , n .CollapseID , r .Header .Get ("apns-collapse-id" ))
258
+ assert .Equal (t , "10" , r .Header .Get ("apns-priority" ))
259
+ assert .Equal (t , n .Topic , r .Header .Get ("apns-topic" ))
260
+ assert .Equal (t , "" , r .Header .Get ("apns-expiration" ))
261
+ }))
262
+ defer server .Close ()
263
+ _ , err := mockClient (server .URL ).Push (n )
264
+ assert .NoError (t , err )
265
+ }
266
+
248
267
func TestPushTypeAlertHeader (t * testing.T ) {
249
268
n := mockNotification ()
250
269
n .PushType = apns .PushTypeAlert
You can’t perform that action at this time.
0 commit comments