Skip to content

Commit 3616cc7

Browse files
authored
Merge pull request #1 from funkenstrahlen/apns-push-type
add support for apns-push-type key
2 parents ffc0c98 + d003b78 commit 3616cc7

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

doc/notification.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ Provide one of the following values:
172172
* `5` - The push message is sent at a time that conserves power on the device receiving it.
173173

174174

175+
#### notification.pushType
176+
177+
(Required when delivering notifications to devices running iOS 13 and later, or watchOS 6 and later. Ignored on earlier system versions.)
178+
179+
The type of the notification. The value of this header is `alert` or `background`. Specify `alert` when the delivery of your notification displays an alert, plays a sound, or badges your app's icon. Specify `background` for silent notifications that do not interact with the user.
180+
181+
The value of this header must accurately reflect the contents of your notification's payload. If there is a mismatch, or if the header is missing on required systems, APNs may delay the delivery of the notification or drop it altogether.
182+
175183
#### notification.collapseId
176184

177185
Multiple notifications with same collapse identifier are displayed to the user as a single notification. The value should not exceed 64 bytes.

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export class Notification {
150150
public priority: number;
151151

152152
public collapseId: string;
153+
public pushType: string;
153154
public threadId: string;
154155

155156
/**

lib/notification/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ Notification.prototype.headers = function headers() {
5858
headers["apns-collapse-id"] = this.collapseId;
5959
}
6060

61+
if (this.pushType) {
62+
headers["apns-push-type"] = this.pushType;
63+
}
64+
6165
return headers;
6266
};
6367

test/notification/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ describe("Notification", function() {
154154
expect(note.headers()).to.have.property("apns-collapse-id", "io.apn.collapse");
155155
});
156156
});
157+
158+
context("pushType is set", function () {
159+
it("contains the apns-push-type header", function () {
160+
note.pushType = "alert";
161+
162+
expect(note.headers()).to.have.property("apns-push-type", "alert");
163+
});
164+
});
157165
});
158166

159167
describe("compile", function() {

0 commit comments

Comments
 (0)