Skip to content

Commit

Permalink
Merge pull request #1 from funkenstrahlen/apns-push-type
Browse files Browse the repository at this point in the history
add support for apns-push-type key
  • Loading branch information
davimacedo authored Jul 25, 2019
2 parents ffc0c98 + d003b78 commit 3616cc7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
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

0 comments on commit 3616cc7

Please sign in to comment.