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 events instead of event in Live Activity push notification payload #148

Merged
merged 2 commits into from
Sep 10, 2024
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.events = "update"
note.event = "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,"events":"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,"event":"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` |
| `events` | `aps.events` | `String` |
| `event` | `aps.event` | `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 events(value) {
set event(value) {
if (typeof value === 'string' || value === undefined) {
this.aps.events = value;
this.aps.event = 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',
'events',
'event',
'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('events', function () {
describe('event', function () {
it('defaults to undefined', function () {
expect(compiledOutput()).to.not.have.nested.property('aps.events');
expect(compiledOutput()).to.not.have.nested.property('aps.event');
});

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

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

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

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

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