Skip to content

Commit 12fc01c

Browse files
committed
feat: Add apns-id header to client return value
1 parent c49e689 commit 12fc01c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lib/client.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ module.exports = function (dependencies) {
503503
Client.prototype.createHeaderObject = function createHeaderObject(
504504
uniqueId,
505505
requestId,
506-
channelId
506+
channelId,
507+
notificationId
507508
) {
508509
const header = {};
509510
if (uniqueId) {
@@ -515,6 +516,9 @@ module.exports = function (dependencies) {
515516
if (channelId) {
516517
header['apns-channel-id'] = channelId;
517518
}
519+
if (notificationId) {
520+
header['apns-id'] = notificationId
521+
}
518522
return header;
519523
};
520524

@@ -531,6 +535,7 @@ module.exports = function (dependencies) {
531535
let uniqueId = null;
532536
let requestId = null;
533537
let channelId = null;
538+
let notificationId = null;
534539
let responseData = '';
535540

536541
const headers = extend(
@@ -561,6 +566,7 @@ module.exports = function (dependencies) {
561566
uniqueId = headers['apns-unique-id'];
562567
requestId = headers['apns-request-id'];
563568
channelId = headers['apns-channel-id'];
569+
notificationId = headers["apns-id"];
564570
});
565571

566572
request.on('data', data => {
@@ -577,7 +583,7 @@ module.exports = function (dependencies) {
577583
if (this.logger.enabled) {
578584
this.logger(`Request ended with status ${status} and responseData: ${responseData}`);
579585
}
580-
const headerObject = this.createHeaderObject(uniqueId, requestId, channelId);
586+
const headerObject = this.createHeaderObject(uniqueId, requestId, channelId, notificationId);
581587

582588
if (status === 200 || status === 201 || status === 204) {
583589
const body = responseData !== '' ? JSON.parse(responseData) : {};

0 commit comments

Comments
 (0)