Skip to content
Open
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
7 changes: 6 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ interface Aps {
badge?: number
sound?: string | ApsSound
"content-available"?: undefined | 1
"content-changed"?: undefined | true
"mutable-content"?: undefined | 1
"url-args"?: string[]
category?: string
Expand Down Expand Up @@ -267,7 +268,7 @@ export class MultiProvider extends EventEmitter {
shutdown(callback?: () => void): Promise<void>;
}

export type NotificationPushType = 'background' | 'alert' | 'voip' | 'pushtotalk' | 'liveactivity' | 'location' | 'complication' | 'fileprovider' | 'mdm';
export type NotificationPushType = 'background' | 'alert' | 'voip' | 'pushtotalk' | 'liveactivity' | 'location' | 'complication' | 'fileprovider' | 'mdm' | 'widgets';

export type ChannelAction = 'create' | 'read' | 'readAll' | 'delete';

Expand Down Expand Up @@ -366,6 +367,10 @@ export class Notification {
*
*/
public mutableContent: boolean;
/**
* Setting this to true will specify "content-changed" in the payload when it is compiled
*/
public contentChanged: boolean;
/**
* The value to specify for the `mdm` field where applicable.
*/
Expand Down
8 changes: 8 additions & 0 deletions lib/notification/apsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ module.exports = {
}
},

set contentChanged(value) {
if (value === true || value === 1) {
this.aps['content-changed'] = true;
} else {
this.aps['content-changed'] = undefined;
}
},

set mdm(value) {
this._mdm = value;
},
Expand Down
1 change: 1 addition & 0 deletions lib/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Notification.prototype = require('./apsProperties');
'sound',
'contentAvailable',
'mutableContent',
'contentChanged',
'mdm',
'urlArgs',
'category',
Expand Down
32 changes: 32 additions & 0 deletions test/notification/apsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,38 @@ describe('Notification', function () {
});
});

describe('content-changed', function () {
it('defaults to undefined', function () {
expect(compiledOutput()).to.not.have.nested.deep.property('aps.content-changed');
});

it('can be set to a boolean value', function () {
note.contentChanged = true;

expect(compiledOutput()).to.have.nested.deep.property('aps.content-changed', true);
});

it('can be set to `1`', function () {
note.contentChanged = 1;

expect(compiledOutput()).to.have.nested.deep.property('aps.content-changed', true);
});

it('can be set to undefined', function () {
note.contentChanged = true;
note.contentChanged = undefined;

expect(compiledOutput()).to.not.have.nested.deep.property('aps.content-changed');
});

describe('setContentChanged', function () {
it('is chainable', function () {
expect(note.setContentChanged(true)).to.equal(note);
expect(compiledOutput()).to.have.nested.deep.property('aps.content-changed', true);
});
});
});

describe('mdm', function () {
it('defaults to undefined', function () {
expect(compiledOutput()).to.not.have.nested.deep.property('mdm');
Expand Down