diff --git a/index.d.ts b/index.d.ts index ced99b46..3cb375dd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 @@ -267,7 +268,7 @@ export class MultiProvider extends EventEmitter { shutdown(callback?: () => void): Promise; } -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'; @@ -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. */ diff --git a/lib/notification/apsProperties.js b/lib/notification/apsProperties.js index b333bff1..55117f31 100644 --- a/lib/notification/apsProperties.js +++ b/lib/notification/apsProperties.js @@ -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; }, diff --git a/lib/notification/index.js b/lib/notification/index.js index 17230441..dedc459d 100644 --- a/lib/notification/index.js +++ b/lib/notification/index.js @@ -45,6 +45,7 @@ Notification.prototype = require('./apsProperties'); 'sound', 'contentAvailable', 'mutableContent', + 'contentChanged', 'mdm', 'urlArgs', 'category', diff --git a/test/notification/apsProperties.js b/test/notification/apsProperties.js index 2f7f611e..20bb32c8 100644 --- a/test/notification/apsProperties.js +++ b/test/notification/apsProperties.js @@ -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');