Skip to content

Commit

Permalink
Merge branch 'master' into localizedSubtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 authored Sep 16, 2024
2 parents 9333d50 + 9b173b4 commit 385ed84
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [6.1.0](https://github.com/parse-community/node-apn/compare/6.0.2...6.1.0) (2024-09-16)


### Features

* Add `dismissal-date` property to Live Activity notifications ([#152](https://github.com/parse-community/node-apn/issues/152)) ([d863f2e](https://github.com/parse-community/node-apn/commit/d863f2e6ce2a58ee92371d69ad8966dd9927e90f))

## [6.0.2](https://github.com/parse-community/node-apn/compare/6.0.1...6.0.2) (2024-09-10)


Expand Down
1 change: 1 addition & 0 deletions doc/notification.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ This table shows the name of the setter, with the key-path of the underlying pro
| `staleDate` | `aps.staleDate` | `Number` |
| `event` | `aps.event` | `String` |
| `contentState` | `aps.content-state` | `Object` |
| `dismissalDate` | `aps.dismissal-date` | `Number` |
| `mdm` | `mdm` | `String` |

When the notification is transmitted these properties will be added to the output before encoding.
Expand Down
6 changes: 6 additions & 0 deletions lib/notification/apsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ module.exports = {
}
},

set dismissalDate(value) {
if (typeof value === 'number' || value === undefined) {
this.aps['dismissal-date'] = value;
}
},

set contentAvailable(value) {
if (value === true || value === 1) {
this.aps['content-available'] = 1;
Expand Down
1 change: 1 addition & 0 deletions lib/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Notification.prototype = require('./apsProperties');
'staleDate',
'event',
'contentState',
'dismissalDate'
].forEach(propName => {
const methodName = 'set' + propName[0].toUpperCase() + propName.slice(1);
Notification.prototype[methodName] = function (value) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@parse/node-apn",
"description": "An interface to the Apple Push Notification service for Node.js",
"version": "6.0.2",
"version": "6.1.0",
"author": "Parse Platform, Andrew Naylor <[email protected]>",
"keywords": [
"apple",
Expand Down
26 changes: 26 additions & 0 deletions test/notification/apsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,32 @@ describe('Notification', function () {
});
});

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

it('can be set to a number', function () {
note.dismissalDate = 123456;

expect(compiledOutput()).to.have.nested.property('aps.dismissal-date', 123456);
});

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

expect(compiledOutput()).to.not.have.nested.property('aps.dismissal-date');
});

describe('setDismissalDate', function () {
it('is chainable', function () {
expect(note.setDismissalDate(123456)).to.equal(note);
expect(compiledOutput()).to.have.nested.property('aps.dismissal-date', 123456);
});
});
});

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

0 comments on commit 385ed84

Please sign in to comment.