Skip to content

add support for apns-push-type key #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/notification.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ Provide one of the following values:
* `5` - The push message is sent at a time that conserves power on the device receiving it.


#### notification.pushType

(Required when delivering notifications to devices running iOS 13 and later, or watchOS 6 and later. Ignored on earlier system versions.)

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.

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.

#### notification.collapseId

Multiple notifications with same collapse identifier are displayed to the user as a single notification. The value should not exceed 64 bytes.
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export class Notification {
public priority: number;

public collapseId: string;
public pushType: string;
public threadId: string;

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ Notification.prototype.headers = function headers() {
headers["apns-collapse-id"] = this.collapseId;
}

if (this.pushType) {
headers["apns-push-type"] = this.pushType;
}

return headers;
};

Expand Down
8 changes: 8 additions & 0 deletions test/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ describe("Notification", function() {
expect(note.headers()).to.have.property("apns-collapse-id", "io.apn.collapse");
});
});

context("pushType is set", function () {
it("contains the apns-push-type header", function () {
note.pushType = "alert";

expect(note.headers()).to.have.property("apns-push-type", "alert");
});
});
});

describe("compile", function() {
Expand Down