Skip to content

Commit d863f2e

Browse files
authored
feat: Add dismissal-date property to Live Activity notifications (#152)
1 parent f1424e6 commit d863f2e

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

doc/notification.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ This table shows the name of the setter, with the key-path of the underlying pro
112112
| `staleDate` | `aps.staleDate` | `Number` |
113113
| `event` | `aps.event` | `String` |
114114
| `contentState` | `aps.content-state` | `Object` |
115+
| `dismissalDate` | `aps.dismissal-date` | `Number` |
115116
| `mdm` | `mdm` | `String` |
116117

117118
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
@@ -113,6 +113,12 @@ module.exports = {
113113
}
114114
},
115115

116+
set dismissalDate(value) {
117+
if (typeof value === 'number' || value === undefined) {
118+
this.aps['dismissal-date'] = value;
119+
}
120+
},
121+
116122
set contentAvailable(value) {
117123
if (value === true || value === 1) {
118124
this.aps['content-available'] = 1;

lib/notification/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Notification.prototype = require('./apsProperties');
5454
'staleDate',
5555
'event',
5656
'contentState',
57+
'dismissalDate'
5758
].forEach(propName => {
5859
const methodName = 'set' + propName[0].toUpperCase() + propName.slice(1);
5960
Notification.prototype[methodName] = function (value) {

test/notification/apsProperties.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,32 @@ describe('Notification', function () {
858858
});
859859
});
860860

861+
describe('dismissal-date', function () {
862+
it('defaults to undefined', function () {
863+
expect(compiledOutput()).to.not.have.nested.property('aps.dismissal-date');
864+
});
865+
866+
it('can be set to a number', function () {
867+
note.dismissalDate = 123456;
868+
869+
expect(compiledOutput()).to.have.nested.property('aps.dismissal-date', 123456);
870+
});
871+
872+
it('can be set to undefined', function () {
873+
note.dismissalDate = 123456;
874+
note.dismissalDate = undefined;
875+
876+
expect(compiledOutput()).to.not.have.nested.property('aps.dismissal-date');
877+
});
878+
879+
describe('setDismissalDate', function () {
880+
it('is chainable', function () {
881+
expect(note.setDismissalDate(123456)).to.equal(note);
882+
expect(compiledOutput()).to.have.nested.property('aps.dismissal-date', 123456);
883+
});
884+
});
885+
});
886+
861887
describe('timestamp', function () {
862888
it('defaults to undefined', function () {
863889
expect(compiledOutput()).to.not.have.nested.property('aps.timestamp');

0 commit comments

Comments
 (0)