Skip to content

Commit 557bfd2

Browse files
set default value for push type to alert
If defined explicitly the passed value for push type is used.
1 parent efadad8 commit 557bfd2

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

spec/APNS.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,29 @@ describe('APNS', () => {
194194
expect(notification.priority).toEqual(priority);
195195
done();
196196
});
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+
});
197220

198221
it('can generate APNS notification from raw data', (done) => {
199222
//Mock request data

src/APNS.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ export class APNS {
216216
notification.topic = headers.topic;
217217
notification.expiry = Math.round(headers.expirationTime / 1000);
218218
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+
}
220224
if (headers.priority) {
221225
// 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.
222226
notification.priority = headers.priority

0 commit comments

Comments
 (0)