Skip to content

Commit b5967b8

Browse files
committed
Fix formatting
1 parent bf48278 commit b5967b8

File tree

11 files changed

+44
-41
lines changed

11 files changed

+44
-41
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,16 @@ const silentPushData = {
531531
```
532532
533533
## FCM
534+
534535
The following parameters are used to create an FCM message (Android/APN):
535536
[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))
536537
Settings:
538+
537539
- `settings.fcm.appName` [firebase app name](https://firebase.google.com/docs/reference/admin/node/firebase-admin.app.app#appname) (required)
538540
- `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'
539541
- `settings.fcm.credential` [firebase credential](https://firebase.google.com/docs/reference/admin/node/firebase-admin.app.credential)
540-
Note: one of `serviceAccountKey`, `credential` fcm options is required
542+
Note: one of `serviceAccountKey`, `credential` fcm options is required
543+
541544
```js
542545
const tokens = [
543546
'e..Gwso:APA91.......7r910HljzGUVS_f...kbyIFk2sK6......D2s6XZWn2E21x',
@@ -576,11 +579,15 @@ pushNotifications.send(tokens, notifications, (error, result) => {
576579
}
577580
});
578581
```
582+
579583
`fcm_notification` - object that will be passed to
584+
580585
```js
581586
new gcm.Message({ ..., notification: data.fcm_notification })
582587
```
588+
583589
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)) :
590+
584591
```json
585592
{
586593
"data": {

src/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ module.exports = {
7171
// contentEncoding: '< Encoding type, e.g.: aesgcm or aes128gcm >'
7272
},
7373
isAlwaysUseFCM: false,
74-
isLegacyGCM: false
74+
isLegacyGCM: false,
7575
},
7676
};

src/push-notifications.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import {
2121
class PN {
2222
constructor(options) {
2323
this.setOptions(options);
24-
this.useFcmOrGcmMethod = this.settings.isLegacyGCM ? GCM_METHOD : FCM_METHOD;
24+
this.useFcmOrGcmMethod = this.settings.isLegacyGCM
25+
? GCM_METHOD
26+
: FCM_METHOD;
2527
}
2628

2729
setOptions(opts) {

src/sendFCM.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ const firebaseAdmin = require('firebase-admin');
22

33
const { FCM_METHOD } = require('./constants');
44
const FcmMessage = require('./utils/fcmMessage');
5-
const {
6-
containsValidRecipients,
7-
} = require('./utils/tools');
5+
const { containsValidRecipients } = require('./utils/tools');
86

97
const getRecipientList = (obj) => {
108
if (obj.tokens) {
@@ -19,7 +17,7 @@ const getRecipientList = (obj) => {
1917
if (obj.topic) {
2018
return [obj.topic];
2119
}
22-
}
20+
};
2321

2422
const sendChunk = (firebaseApp, recipients, message) => {
2523
const firebaseMessage = message.buildWithRecipients(recipients);
@@ -128,4 +126,4 @@ const sendFCM = (regIds, data, settings) => {
128126
});
129127
};
130128

131-
module.exports = sendFCM;
129+
module.exports = sendFCM;

src/sendGCM.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
const gcm = require('node-gcm');
22
const { GCM_METHOD } = require('./constants');
3-
const {
4-
containsValidRecipients,
5-
buildGcmMessage,
6-
} = require('./utils/tools');
3+
const { containsValidRecipients, buildGcmMessage } = require('./utils/tools');
74

85
const getRecipientList = (obj) => {
96
if (obj.registrationTokens) {
@@ -15,7 +12,7 @@ const getRecipientList = (obj) => {
1512
if (obj.condition) {
1613
return [obj.condition];
1714
}
18-
}
15+
};
1916

2017
const sendChunk = (GCMSender, recipients, message, retries) =>
2118
new Promise((resolve) => {
@@ -79,7 +76,7 @@ const sendGCM = (regIds, data, settings) => {
7976
const promises = [];
8077

8178
const message = buildGcmMessage(data, opts);
82-
79+
8380
let chunk = 0;
8481

8582
/* allow to override device tokens with custom `to` or `condition` field:

src/utils/fcmMessage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ class FcmMessage {
7979
}
8080
}
8181

82-
module.exports = FcmMessage;
82+
module.exports = FcmMessage;

src/utils/tools.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ const extractExpiry = R.cond([
3030
const getPropValueOrUndefinedIfIsSilent = (propName, data) => {
3131
if (data.silent) {
3232
return undefined;
33-
}
34-
else return data[propName];
35-
}
33+
} else return data[propName];
34+
};
3635

3736
const toJSONorUndefined = R.when(
3837
R.is(String),
@@ -142,7 +141,7 @@ const buildGcmMessage = (data, options) => {
142141
};
143142

144143
const buildApnsMessage = (data) => {
145-
console.log('data', data)
144+
console.log('data', data);
146145
const message = new ApnsMessage({
147146
retryLimit: data.retries || -1,
148147
expiry: extractExpiry(data),
@@ -166,7 +165,7 @@ const buildApnsMessage = (data) => {
166165
threadId: data.threadId,
167166
pushType: data.pushType,
168167
});
169-
console.log('message', message)
168+
console.log('message', message);
170169

171170
if (data.rawPayload) {
172171
message.rawPayload = data.rawPayload;
@@ -183,4 +182,4 @@ module.exports = {
183182

184183
buildApnsMessage,
185184
buildGcmMessage,
186-
};
185+
};

test/push-notifications/basic.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ describe('push-notifications: instantiation and class properties', () => {
4343
},
4444
fcm: {
4545
name: 'testAppName',
46-
serviceAccountKey: require(path.resolve(
47-
'test/send/FCM-service-account-key.json'
48-
)),
46+
serviceAccountKey: require(
47+
path.resolve('test/send/FCM-service-account-key.json')
48+
),
4949
},
5050
apn: {
5151
token: {
@@ -251,9 +251,9 @@ describe('push-notifications: instantiation and class properties', () => {
251251
const settings = {
252252
fcm: {
253253
name: 'testAppName',
254-
serviceAccountKey: require(path.resolve(
255-
'test/send/FCM-service-account-key.json'
256-
)),
254+
serviceAccountKey: require(
255+
path.resolve('test/send/FCM-service-account-key.json')
256+
),
257257
},
258258
isLegacyGCM: false,
259259
};
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"type": "service_account",
3-
"project_id": "tjkfdgkj-sfggtht-sdf",
4-
"private_key_id": "45674567rtgweryer65u45687ws",
5-
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgZQKBgH3+\nYwwi1GLdC7gliFyczOt2x/LC1PFhtk2K5h2CbMZVUYO0SvTjr/E5MWDra+eKLxdO\nPPcJgipS4lYeziJMCgRD9LiY4xeuUcdt1eR\n+xqoGPVTftTZiSyplhpdABcO9B7mrOxBTf6sX4tJAoGBANq/G9uy4rQ2JwcdX7Aq\nVykfyOrirjuA+oAH7m9bnnrvLFZavvz3tlWAxgmu+3zjXdD0pbLsn7mePBmLVAdh\n28I2dHj0BAZHd95Hnn+X1tJU26+v7SAtzQjQhskEbAXrPJ8rFyhL6RrswNrzJt0f\ntDV27cmQkzhvIDIvof4f97W+\n-----END PRIVATE KEY-----\n",
6-
"client_email": "firebase-adminsdk-p7o1d@jkfdgkj-sfggtht-sdf.iam.gserviceaccount.com",
7-
"client_id": "5475678568568568568",
8-
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
9-
"token_uri": "https://oauth2.googleapis.com/token",
10-
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11-
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-p7o1d%40agr-sdfg-gafdsarg.iam.gserviceaccount.com",
12-
"universe_domain": "googleapis.com"
13-
}
2+
"type": "service_account",
3+
"project_id": "tjkfdgkj-sfggtht-sdf",
4+
"private_key_id": "45674567rtgweryer65u45687ws",
5+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgZQKBgH3+\nYwwi1GLdC7gliFyczOt2x/LC1PFhtk2K5h2CbMZVUYO0SvTjr/E5MWDra+eKLxdO\nPPcJgipS4lYeziJMCgRD9LiY4xeuUcdt1eR\n+xqoGPVTftTZiSyplhpdABcO9B7mrOxBTf6sX4tJAoGBANq/G9uy4rQ2JwcdX7Aq\nVykfyOrirjuA+oAH7m9bnnrvLFZavvz3tlWAxgmu+3zjXdD0pbLsn7mePBmLVAdh\n28I2dHj0BAZHd95Hnn+X1tJU26+v7SAtzQjQhskEbAXrPJ8rFyhL6RrswNrzJt0f\ntDV27cmQkzhvIDIvof4f97W+\n-----END PRIVATE KEY-----\n",
6+
"client_email": "firebase-adminsdk-p7o1d@jkfdgkj-sfggtht-sdf.iam.gserviceaccount.com",
7+
"client_id": "5475678568568568568",
8+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
9+
"token_uri": "https://oauth2.googleapis.com/token",
10+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-p7o1d%40agr-sdfg-gafdsarg.iam.gserviceaccount.com",
12+
"universe_domain": "googleapis.com"
13+
}

test/send/sendFCM.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ describe('push-notifications-fcm', () => {
7979
.catch(done);
8080
});
8181
});
82-
});
82+
});

0 commit comments

Comments
 (0)