Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Incorrect field name event instead of events in Live Activity push notification payload #133

Merged
merged 2 commits into from
Jul 21, 2023
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ note.pushType = "liveactivity",
note.relevanceScore = 75,
note.timestamp = Math.floor(Date.now() / 1000); // Current time
note.staleDate = Math.floor(Date.now() / 1000) + (8 * 3600); // Expires 8 hour from now.
note.event = "update"
note.events = "update"
note.contentState = {}
```

Expand All @@ -179,7 +179,7 @@ This will result in the the following notification payload being sent to the dev


```json
{"messageFrom":"John Appleseed","aps":{"badge":3,"sound":"ping.aiff","alert":"\uD83D\uDCE7 \u2709 You have a new message", "relevance-score":75,"timestamp":1683129662,"stale-date":1683216062,"event":"update","content-state":{}}}
{"messageFrom":"John Appleseed","aps":{"badge":3,"sound":"ping.aiff","alert":"\uD83D\uDCE7 \u2709 You have a new message", "relevance-score":75,"timestamp":1683129662,"stale-date":1683216062,"events":"update","content-state":{}}}
```

You should only create one `Provider` per-process for each certificate/key pair you have. You do not need to create a new `Provider` for each notification. If you are only sending notifications to one app then there is no need for more than one `Provider`.
Expand Down
2 changes: 1 addition & 1 deletion doc/notification.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ This table shows the name of the setter, with the key-path of the underlying pro
| `relevanceScore` | `aps.relevance-score` | `Number` |
| `timestamp` | `aps.timestamp` | `Number` |
| `staleDate` | `aps.staleDate` | `Number` |
| `event` | `aps.event` | `String` |
| `events` | `aps.events` | `String` |
| `contentState` | `aps.content-state` | `Object` |
| `mdm` | `mdm` | `String` |

Expand Down
4 changes: 2 additions & 2 deletions lib/notification/apsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ module.exports = {
}
},

set event(value) {
set events(value) {
if (typeof value === 'string' || value === undefined) {
this.aps.event = value;
this.aps.events = value;
}
},

Expand Down
2 changes: 1 addition & 1 deletion lib/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Notification.prototype = require('./apsProperties');
'relevanceScore',
'timestamp',
'staleDate',
'event',
'events',
'contentState',
].forEach(propName => {
const methodName = 'set' + propName[0].toUpperCase() + propName.slice(1);
Expand Down
20 changes: 10 additions & 10 deletions test/notification/apsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,28 +832,28 @@ describe('Notification', function () {
});
});

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

it('can be set to a string', function () {
note.event = 'the-event';
note.events = 'the-event';

expect(compiledOutput()).to.have.nested.property('aps.event', 'the-event');
expect(compiledOutput()).to.have.nested.property('aps.events', 'the-event');
});

it('can be set to undefined', function () {
note.event = 'the-event';
note.event = undefined;
note.events = 'the-event';
note.events = undefined;

expect(compiledOutput()).to.not.have.nested.property('aps.event');
expect(compiledOutput()).to.not.have.nested.property('aps.events');
});

describe('setEvent', function () {
describe('setEvents', function () {
it('is chainable', function () {
expect(note.setEvent('the-event')).to.equal(note);
expect(compiledOutput()).to.have.nested.property('aps.event', 'the-event');
expect(note.setEvents('the-event')).to.equal(note);
expect(compiledOutput()).to.have.nested.property('aps.events', 'the-event');
});
});
});
Expand Down