Skip to content

Commit d059556

Browse files
committed
Expose content-changed from aps dict as contentChanged property and add tests
1 parent e335c46 commit d059556

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ export class Notification {
367367
*
368368
*/
369369
public mutableContent: boolean;
370+
/**
371+
* Setting this to true will specify "content-changed" in the payload when it is compiled
372+
*/
373+
public contentChanged: boolean;
370374
/**
371375
* The value to specify for the `mdm` field where applicable.
372376
*/

lib/notification/apsProperties.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ module.exports = {
145145
}
146146
},
147147

148+
set contentChanged(value) {
149+
if (value === true || value === 1) {
150+
this.aps['content-changed'] = true;
151+
} else {
152+
this.aps['content-changed'] = undefined;
153+
}
154+
},
155+
148156
set mdm(value) {
149157
this._mdm = value;
150158
},

lib/notification/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Notification.prototype = require('./apsProperties');
4545
'sound',
4646
'contentAvailable',
4747
'mutableContent',
48+
'contentChanged',
4849
'mdm',
4950
'urlArgs',
5051
'category',

test/notification/apsProperties.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,38 @@ describe('Notification', function () {
761761
});
762762
});
763763

764+
describe('content-changed', function () {
765+
it('defaults to undefined', function () {
766+
expect(compiledOutput()).to.not.have.nested.deep.property('aps.content-changed');
767+
});
768+
769+
it('can be set to a boolean value', function () {
770+
note.contentChanged = true;
771+
772+
expect(compiledOutput()).to.have.nested.deep.property('aps.content-changed', true);
773+
});
774+
775+
it('can be set to `1`', function () {
776+
note.contentChanged = 1;
777+
778+
expect(compiledOutput()).to.have.nested.deep.property('aps.content-changed', true);
779+
});
780+
781+
it('can be set to undefined', function () {
782+
note.contentChanged = true;
783+
note.contentChanged = undefined;
784+
785+
expect(compiledOutput()).to.not.have.nested.deep.property('aps.content-changed');
786+
});
787+
788+
describe('setContentChanged', function () {
789+
it('is chainable', function () {
790+
expect(note.setContentChanged(true)).to.equal(note);
791+
expect(compiledOutput()).to.have.nested.deep.property('aps.content-changed', true);
792+
});
793+
});
794+
});
795+
764796
describe('mdm', function () {
765797
it('defaults to undefined', function () {
766798
expect(compiledOutput()).to.not.have.nested.deep.property('mdm');

0 commit comments

Comments
 (0)