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

Bump from upstream #7

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
99b1db7
Bump actions versions to v4
alex-friedl Apr 3, 2024
d5444b3
Bump web-push to 3.6.7
alex-friedl Apr 3, 2024
03eeaac
Upgrade ramda to 0.29.1
alex-friedl Apr 3, 2024
d389481
Merge pull request #202 from appfeel/dev/bump-deps
alex-friedl Apr 3, 2024
6980885
Bump follow-redirects from 1.15.5 to 1.15.6
dependabot[bot] Apr 3, 2024
98f124a
Bump ip from 1.1.8 to 1.1.9
dependabot[bot] Apr 3, 2024
fb33ffc
Bump debug from 3.2.6 to 4.3.3
dependabot[bot] Apr 3, 2024
c5580c0
Merge pull request #201 from appfeel/dependabot/npm_and_yarn/follow-r…
alex-friedl Apr 3, 2024
b1d5af0
Merge pull request #200 from appfeel/dependabot/npm_and_yarn/ip-1.1.9
alex-friedl Apr 3, 2024
5a369b8
Merge pull request #196 from appfeel/dependabot/npm_and_yarn/debug-4.3.3
alex-friedl Apr 3, 2024
597836f
Release 2.1.2
alex-friedl Apr 3, 2024
271f0f6
Bump dev dependencies
alex-friedl Apr 3, 2024
5ee1cb0
Require node version 14
alex-friedl Apr 3, 2024
6125d3d
Bump @parse/node-apn to 6.0.1
alex-friedl Apr 3, 2024
9fdadc2
Merge pull request #203 from appfeel/dev/v3
alex-friedl Apr 3, 2024
298a88b
Release 3.0.0
alex-friedl Apr 3, 2024
ef16496
Fix required node version in README
alex-friedl Apr 3, 2024
2ce401a
Bump braces from 3.0.2 to 3.0.3
dependabot[bot] Jun 16, 2024
a072536
re-do PR from original repo and fix tests
wcalebgray Jun 18, 2024
912190b
Merge pull request #206 from appfeel/dependabot/npm_and_yarn/braces-3…
alex-friedl Jun 19, 2024
bf48278
Merge pull request #207 from wcalebgray/fcm-v2
alex-friedl Jun 19, 2024
b5967b8
Fix formatting
alex-friedl Jun 19, 2024
b997d68
Fix linter
alex-friedl Jun 19, 2024
925cfcf
Remove console logs
alex-friedl Jun 19, 2024
1efe289
Bump some dependencies
alex-friedl Jun 19, 2024
02b8051
Fix getRecipientList linter warning
alex-friedl Jun 19, 2024
f6724d1
Fix friend_id in README
alex-friedl Jun 19, 2024
cf87412
Move setting of useFcmOrGcmMethod to setOptions
alex-friedl Jun 19, 2024
841dffc
Fix linter in sendGCM
alex-friedl Jun 19, 2024
4b3c3f3
Release 3.1.0
alex-friedl Jun 19, 2024
d4ac65f
add passthrough for settings to enable data notification
wcalebgray Jun 20, 2024
5c2d937
fix linter
wcalebgray Jun 20, 2024
b438728
Merge pull request #209 from wcalebgray/fcm-data-upgrade
alex-friedl Jun 21, 2024
5a1a338
Release 3.1.1
alex-friedl Jun 21, 2024
9bae368
Merge branch 'master' of github.com:appfeel/node-pushnotifications in…
dchymko Aug 21, 2024
7ac6cb4
add our custom property to the relocated function
dchymko Aug 21, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x, 20.x]
node-version: [14.x, 16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
Expand Down
112 changes: 109 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ A node.js module for interfacing with Apple Push Notification, Google Cloud Mess
- [Features](#features)
- [Usage](#usage)
- [GCM](#gcm)
- [FCM](#fcm)
- [APN](#apn)
- [WNS](#wns)
- [ADM](#adm)
Expand All @@ -30,7 +31,7 @@ npm install node-pushnotifications --save

## Requirements

Node version >= 12.x.x
Node version >= 14.x.x

## Features

Expand All @@ -55,6 +56,11 @@ const settings = {
phonegap: false, // phonegap compatibility mode, see below (defaults to false)
...
},
fcm: {
appName: 'localFcmAppName',
serviceAccountKey: require('../firebase-project-service-account-key.json'), // firebase service-account-file.json,
credential: null // 'firebase-admin' Credential interface
},
apn: {
token: {
key: './certs/key.p8', // optionally: fs.readFileSync('./certs/key.p8')
Expand Down Expand Up @@ -86,12 +92,15 @@ const settings = {
contentEncoding: 'aes128gcm',
headers: {}
},
isAlwaysUseFCM: false, // true all messages will be sent through node-gcm (which actually uses FCM)
isAlwaysUseFCM: false, // true all messages will be sent through gcm/fcm api
isLegacyGCM: false // if true gcm messages will be sent through node-gcm (deprecated api), if false gcm messages will be sent through 'firebase-admin' lib

};
const push = new PushNotifications(settings);
```

- GCM options: see [node-gcm](https://github.com/ToothlessGear/node-gcm#custom-gcm-request-options)
- FCM options: see [firebase-admin](https://firebase.google.com/docs/admin/setup) (read [FCM](#fcm) section below!)
- APN options: see [node-apn](https://github.com/node-apn/node-apn/blob/master/doc/provider.markdown)
- ADM options: see [node-adm](https://github.com/umano/node-adm)
- WNS options: see [wns](https://github.com/tjanczuk/wns)
Expand Down Expand Up @@ -486,7 +495,8 @@ The following parameters are used to create an APN message:
collapseId: data.collapseKey,
mutableContent: data.mutableContent || 0,
threadId: data.threadId,
pushType: data.pushType
pushType: data.pushType,
rawPayload: data.rawPayload
}
```

Expand All @@ -496,6 +506,7 @@ _data is the parameter in `push.send(registrationIds, data)`_
- **Please note** that `topic` is required ([see node-apn docs](https://github.com/node-apn/node-apn/blob/master/doc/notification.markdown#notificationtopic)). When using token-based authentication, specify the bundle ID of the app.
When using certificate-based authentication, the topic is usually your app's bundle ID.
More details can be found under https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns
- `rawPayload` (hidden 'node-apn' lib notification param) [source code](https://github.com/node-apn/node-apn/blob/master/lib/notification/index.js#L99) this param will replace all payload

### Silent push notifications

Expand All @@ -519,6 +530,101 @@ const silentPushData = {
}
```

## FCM

The following parameters are used to create an FCM message (Android/APN):
[node-gcm](https://github.com/ToothlessGear/node-gcm) lib for `GCM` method use old firebase api (will be [deprecated ](https://firebase.google.com/docs/cloud-messaging/migrate-v1?hl=en&authuser=0))
Settings:

- `settings.fcm.appName` [firebase app name](https://firebase.google.com/docs/reference/admin/node/firebase-admin.app.app#appname) (required)
- `settings.fcm.serviceAccountKey` [firebase service account file](https://firebase.google.com/docs/admin/setup#initialize_the_sdk_in_non-google_environments) use downloaded 'service-account-file.json'
- `settings.fcm.credential` [firebase credential](https://firebase.google.com/docs/reference/admin/node/firebase-admin.app.credential)
Note: one of `serviceAccountKey`, `credential` fcm options is required

```js
const tokens = [
'e..Gwso:APA91.......7r910HljzGUVS_f...kbyIFk2sK6......D2s6XZWn2E21x',
];

const notifications = {
collapseKey: Math.random().toString().replace('0.', ''),
priority: 'high',
sound: 'default',
title: 'Title 1',
body: 'Body 2',
// titleLocKey: 'GREETING',
// titleLocArgs: ['Smith', 'M'],
// fcm_notification: {
// title: 'Title 1',
// body: 'Body 2',
// sound: 'default',
// default_vibrate_timings: true,
// },
// alert: {
// title: 'Title 2',
// body: 'Body 2'
// },
custom: {
friend_id: 54657,
list_id: 'N7jSif1INyZkA7r910HljzGUVS',
},
};

pushNotifications.send(tokens, notifications, (error, result) => {
if (error) {
console.log('[error]', error);
throw error;
} else {
console.log('[result]', result, result.at(0));
}
});
```

`fcm_notification` - object that will be passed to

```js
new gcm.Message({ ..., notification: data.fcm_notification })
```

Fcm object that will be sent to provider ([Fcm message format](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#Message)) :

```json
{
"data": {
"friend_id": "54657",
"list_id": "N7jSif1INyZkA7r910HljzGUVS"
},
"android": {
"collapse_key": "5658586678087056",
"priority": "high",
"notification": {
"title": "Title 1",
"body": "Body 2",
"sound": "default"
},
"ttl": 2419200000
},
"apns": {
"headers": {
"apns-expiration": "1697456586",
"apns-collapse-id": "5658586678087056"
},
"payload": {
"aps": {
"sound": "default",
"alert": {
"title": "Title 1",
"body": "Body 2"
}
}
}
},
"tokens": [
"e..Gwso:APA91.......7r910HljzGUVS_f...kbyIFk2sK6......D2s6XZWn2E21x"
]
}
```

## WNS

The following fields are used to create a WNS message:
Expand Down
Loading
Loading