Skip to content

Commit 5876a59

Browse files
authored
fix: Incorrect field name events instead of event in Live Activity push notification payload (#148)
1 parent 4cf2c03 commit 5876a59

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ note.pushType = "liveactivity",
163163
note.relevanceScore = 75,
164164
note.timestamp = Math.floor(Date.now() / 1000); // Current time
165165
note.staleDate = Math.floor(Date.now() / 1000) + (8 * 3600); // Expires 8 hour from now.
166-
note.events = "update"
166+
note.event = "update"
167167
note.contentState = {}
168168
```
169169

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

180180

181181
```json
182-
{"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":{}}}
182+
{"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":{}}}
183183
```
184184

185185
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`.

doc/notification.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ This table shows the name of the setter, with the key-path of the underlying pro
110110
| `relevanceScore` | `aps.relevance-score` | `Number` |
111111
| `timestamp` | `aps.timestamp` | `Number` |
112112
| `staleDate` | `aps.staleDate` | `Number` |
113-
| `events` | `aps.events` | `String` |
113+
| `event` | `aps.event` | `String` |
114114
| `contentState` | `aps.content-state` | `Object` |
115115
| `mdm` | `mdm` | `String` |
116116

lib/notification/apsProperties.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ module.exports = {
101101
}
102102
},
103103

104-
set events(value) {
104+
set event(value) {
105105
if (typeof value === 'string' || value === undefined) {
106-
this.aps.events = value;
106+
this.aps.event = value;
107107
}
108108
},
109109

lib/notification/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Notification.prototype = require('./apsProperties');
5252
'relevanceScore',
5353
'timestamp',
5454
'staleDate',
55-
'events',
55+
'event',
5656
'contentState',
5757
].forEach(propName => {
5858
const methodName = 'set' + propName[0].toUpperCase() + propName.slice(1);

test/notification/apsProperties.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -832,28 +832,28 @@ describe('Notification', function () {
832832
});
833833
});
834834

835-
describe('events', function () {
835+
describe('event', function () {
836836
it('defaults to undefined', function () {
837-
expect(compiledOutput()).to.not.have.nested.property('aps.events');
837+
expect(compiledOutput()).to.not.have.nested.property('aps.event');
838838
});
839839

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

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

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

850-
expect(compiledOutput()).to.not.have.nested.property('aps.events');
850+
expect(compiledOutput()).to.not.have.nested.property('aps.event');
851851
});
852852

853-
describe('setEvents', function () {
853+
describe('setEvent', function () {
854854
it('is chainable', function () {
855-
expect(note.setEvents('the-event')).to.equal(note);
856-
expect(compiledOutput()).to.have.nested.property('aps.events', 'the-event');
855+
expect(note.setEvent('the-event')).to.equal(note);
856+
expect(compiledOutput()).to.have.nested.property('aps.event', 'the-event');
857857
});
858858
});
859859
});

0 commit comments

Comments
 (0)