File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,29 @@ describe('APNS', () => {
194
194
expect ( notification . priority ) . toEqual ( priority ) ;
195
195
done ( ) ;
196
196
} ) ;
197
+
198
+ it ( 'sets push type to alert if not defined explicitly' , ( done ) => {
199
+ //Mock request data
200
+ let data = {
201
+ 'alert' : 'alert' ,
202
+ 'title' : 'title' ,
203
+ 'badge' : 100 ,
204
+ 'sound' : 'test' ,
205
+ 'content-available' : 1 ,
206
+ 'mutable-content' : 1 ,
207
+ 'category' : 'INVITE_CATEGORY' ,
208
+ 'threadId' : 'a-thread-id' ,
209
+ 'key' : 'value' ,
210
+ 'keyAgain' : 'valueAgain'
211
+ } ;
212
+ let expirationTime = 1454571491354 ;
213
+ let collapseId = "collapseIdentifier" ;
214
+
215
+ let notification = APNS . _generateNotification ( data , { expirationTime : expirationTime , collapseId : collapseId } ) ;
216
+
217
+ expect ( notification . pushType ) . toEqual ( 'alert' ) ;
218
+ done ( ) ;
219
+ } ) ;
197
220
198
221
it ( 'can generate APNS notification from raw data' , ( done ) => {
199
222
//Mock request data
Original file line number Diff line number Diff line change @@ -216,7 +216,11 @@ export class APNS {
216
216
notification . topic = headers . topic ;
217
217
notification . expiry = Math . round ( headers . expirationTime / 1000 ) ;
218
218
notification . collapseId = headers . collapseId ;
219
- notification . pushType = headers . pushType
219
+ // set alert as default push type. If push type is not set notifications are not delivered to devices running iOS 13, watchOS 6 and later.
220
+ notification . pushType = 'alert' ;
221
+ if ( headers . pushType ) {
222
+ notification . pushType = headers . pushType ;
223
+ }
220
224
if ( headers . priority ) {
221
225
// if headers priority is not set 'node-apn' defaults it to 5 which is min. required value for background pushes to launch the app in background.
222
226
notification . priority = headers . priority
You can’t perform that action at this time.
0 commit comments