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

Upgrade APN Library & Support Time-Sensitive Notifications #8047

Merged
merged 5 commits into from
Aug 5, 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
3 changes: 2 additions & 1 deletion lib/server/loop.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//'use strict';

const apn = require('apn');
const apn = require('@parse/node-apn');

function init (env, ctx) {

Expand Down Expand Up @@ -128,6 +128,7 @@ function init (env, ctx) {
notification.topic = loopSettings.bundleIdentifier;
notification.contentAvailable = 1;
notification.payload = payload;
notification.interruptionLevel = "time-sensitive"

provider.send(notification, [loopSettings.deviceToken]).then( (response) => {
if (response.sent && response.sent.length > 0) {
Expand Down
148 changes: 46 additions & 102 deletions package-lock.json

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

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@
"dependencies": {
"@babel/core": "^7.18.10",
"@babel/preset-env": "^7.18.10",
Copy link
Contributor Author

@gestrich gestrich Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this package using the command:

npm install @parse/node-apn

I originally tried this from node version 18* but it added a bunch of changes to the file unrelated to my update (adding the prefix "node_modules" to each depedency). So I downgraded my node to an earlier version, v14.21.3, per some advice from SO and then ran the command again.

"@parse/node-apn": "^5.1.3",
"acorn": "^8.0.5",
"acorn-jsx": "^5.3.1",
"apn": "^2.2.0",
"async": "^0.9.2",
"babel-loader": "^8.2.5",
Copy link
Contributor Author

@gestrich gestrich Jul 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the original PR when the prior APN package was added, I see the "pem" and "base64url" libraries were added in the same PR. Those don't seem needed from what I can tell since upgrading the library. Below is the output of depcheck right after I removed apn, which shows those as unused. So I've removed from now but let me know if there is something I'm missing.

https://github.com/nightscout/cgm-remote-monitor/pull/5043/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519

depcheck
Unused dependencies
* acorn
* acorn-jsx
* base64url
* buffer
* crypto-browserify
* moment-locales-webpack-plugin
* pem
* process
* stream-browserify
* swagger-ui-dist
* webpack-cli
Unused devDependencies
* @types/tough-cookie
....

"base64url": "^3.0.1",
"body-parser": "^1.19.0",
"bootevent": "0.0.1",
"braces": "^3.0.2",
Expand Down Expand Up @@ -120,7 +119,6 @@
"nightscout-connect": "^0.0.6",
"node-cache": "^4.2.1",
"parse-duration": "^0.1.3",
"pem": "^1.14.4",
"process": "^0.11.10",
"pushover-notifications": "^1.2.2",
"random-token": "0.0.8",
Expand Down