Skip to content

Commit

Permalink
Merge branch 'master' into snyk-fix-5f7b5cb3bd4b544b4d3254c5227242a2
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Sep 27, 2024
2 parents 3ac95b5 + 9eb54f1 commit 4dfab0f
Show file tree
Hide file tree
Showing 10 changed files with 359 additions and 65 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Dependabot dependency updates
# Docs: https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm"
# Location of package-lock.json
directory: "/"
# Check daily for updates
schedule:
interval: "daily"
commit-message:
# Set commit message prefix
prefix: "refactor"
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# [6.2.0](https://github.com/parse-community/node-apn/compare/6.1.0...6.2.0) (2024-09-25)


### Features

* Add fields `subtitleLocKey`, `subtitleLocArgs` for localized subtitle and arguments in notifications ([#154](https://github.com/parse-community/node-apn/issues/154)) ([c885405](https://github.com/parse-community/node-apn/commit/c885405e10c9d1ec15968c42d410ce4f56dfbf04))

# [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)


### Bug Fixes

* Incorrect field name `events` instead of `event` in Live Activity push notification payload ([#148](https://github.com/parse-community/node-apn/issues/148)) ([5876a59](https://github.com/parse-community/node-apn/commit/5876a59fcd04c53ccd85ae8ea06a51e2cf119993))

## [6.0.1](https://github.com/parse-community/node-apn/compare/6.0.0...6.0.1) (2023-10-20)


Expand Down
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
5 changes: 4 additions & 1 deletion doc/notification.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ This table shows the name of the setter, with the key-path of the underlying pro
| `title` | `aps.alert.title` | `String` |
| `titleLocKey` | `aps.alert.title-loc-key` | `String` |
| `titleLocArgs` | `aps.alert.title-loc-args` | `Array` |
| `subtitleLocKey` | `aps.alert.subtitle-loc-key` | `String` |
| `subtitleLocArgs` | `aps.alert.subtitle-loc-args` | `Array` |
| `action` | `aps.alert.action` | `String` |
| `actionLocKey` | `aps.alert.action-loc-key` | `String` |
| `launchImage` | `aps.launch-image` | `String` |
Expand All @@ -110,8 +112,9 @@ 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` |
| `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
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ interface ApsAlert {
title?: string
"title-loc-key"?: string
"title-loc-args"?: any[]
"subtitle-loc-key"?: string
"subtitle-loc-args"?: any[]
action?: string
"action-loc-key"?: string
}
Expand Down Expand Up @@ -173,6 +175,8 @@ export interface NotificationAlertOptions {
body: string;
"title-loc-key"?: string;
"title-loc-args"?: string[];
"subtitle-loc-key"?: string;
"subtitle-loc-args"?: string[];
"action-loc-key"?: string;
"loc-key"?: string;
"loc-args"?: string[];
Expand Down
20 changes: 18 additions & 2 deletions lib/notification/apsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ module.exports = {
this.aps.alert['title-loc-args'] = value;
},

set subtitleLocKey(value) {
this.prepareAlert();
this.aps.alert['subtitle-loc-key'] = value;
},

set subtitleLocArgs(value) {
this.prepareAlert();
this.aps.alert['subtitle-loc-args'] = value;
},

set action(value) {
this.prepareAlert();
this.aps.alert.action = value;
Expand Down Expand Up @@ -101,9 +111,9 @@ module.exports = {
}
},

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

Expand All @@ -113,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
5 changes: 4 additions & 1 deletion lib/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Notification.prototype = require('./apsProperties');
'subtitle',
'titleLocKey',
'titleLocArgs',
'subtitleLocKey',
'subtitleLocArgs',
'action',
'actionLocKey',
'launchImage',
Expand All @@ -52,8 +54,9 @@ Notification.prototype = require('./apsProperties');
'relevanceScore',
'timestamp',
'staleDate',
'events',
'event',
'contentState',
'dismissalDate'
].forEach(propName => {
const methodName = 'set' + propName[0].toUpperCase() + propName.slice(1);
Notification.prototype[methodName] = function (value) {
Expand Down
Loading

0 comments on commit 4dfab0f

Please sign in to comment.