Skip to content

Commit eb497ef

Browse files
authored
Merge branch 'master' into target-content-id
2 parents a75a5f0 + b27fa32 commit eb497ef

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

doc/notification.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ This table shows the name of the setter, with the key-path of the underlying pro
106106
| `category` | `aps.category` | `String` |
107107
| `targetContentIdentifier` | `aps.target-content-id` | `String` |
108108
| `threadId` | `aps.thread-id` | `String` |
109+
| `interruptionLevel` | `aps.interruption-level` | `String` |
109110
| `mdm` | `mdm` | `String` |
110111

111112
When the notification is transmitted these properties will be added to the output before encoding.

lib/notification/apsProperties.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ module.exports = {
128128
}
129129
},
130130

131+
set interruptionLevel(value) {
132+
if(typeof value === "string" || value === undefined) {
133+
this.aps["interruption-level"] = value;
134+
}
135+
},
136+
131137
prepareAlert: function () {
132138
if (typeof this.aps.alert !== "object") {
133139
this.aps.alert = {"body": this.aps.alert};

lib/notification/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Notification.prototype = require("./apsProperties");
2727
["payload", "expiry", "priority", "alert", "body", "locKey",
2828
"locArgs", "title", "subtitle", "titleLocKey", "titleLocArgs", "action",
2929
"actionLocKey", "launchImage", "badge", "sound", "contentAvailable",
30-
"mutableContent", "mdm", "urlArgs", "category", "targetContentIdentifier",
31-
"threadId"].forEach( propName => {
30+
"mutableContent", "mdm", "urlArgs", "category", "targetContentIdentifier",
31+
"threadId", "interruptionLevel"].forEach( propName => {
3232
const methodName = "set" + propName[0].toUpperCase() + propName.slice(1);
3333
Notification.prototype[methodName] = function (value) {
3434
this[propName] = value;

test/notification/apsProperties.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,32 @@ describe("Notification", function() {
740740
});
741741
});
742742

743+
describe("interruption-level", function() {
744+
it("defaults to undefined", function() {
745+
expect(compiledOutput()).to.not.have.nested.property("aps.interruption\-level");
746+
});
747+
748+
it("can be set to a string", function() {
749+
note.interruptionLevel = "the-interruption-level";
750+
751+
expect(compiledOutput()).to.have.nested.property("aps.interruption\-level", "the-interruption-level");
752+
});
753+
754+
it("can be set to undefined", function() {
755+
note.interruptionLevel = "the-interruption-level";
756+
note.interruptionLevel = undefined;
757+
758+
expect(compiledOutput()).to.not.have.nested.property("aps.interruption\-level");
759+
});
760+
761+
describe("setInterruptionLevel", function () {
762+
it("is chainable", function () {
763+
expect(note.setInterruptionLevel("the-interruption-level")).to.equal(note);
764+
expect(compiledOutput()).to.have.nested.property("aps.interruption\-level", "the-interruption-level");
765+
});
766+
});
767+
});
768+
743769
context("when no aps properties are set", function() {
744770
it("is not present", function() {
745771
expect(compiledOutput().aps).to.be.undefined;

0 commit comments

Comments
 (0)