Skip to content

Commit 6ed118a

Browse files
committed
Remove support for legacy GCM API
1 parent 743a9c3 commit 6ed118a

File tree

16 files changed

+101
-1584
lines changed

16 files changed

+101
-1584
lines changed

.github/copilot-instructions.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## Project Overview
44

5-
This repository implements a Node.js module for sending push notifications across multiple platforms: Apple (APN), Google (GCM/FCM), Windows (WNS), Amazon (ADM), and Web-Push. The core logic is in `lib/` and `src/`, with each platform handled by a dedicated file (e.g., `sendAPN.js`, `sendFCM.js`).
5+
This repository implements a Node.js module for sending push notifications across multiple platforms: Apple (APN), Google (FCM), Windows (WNS), Amazon (ADM), and Web-Push. The core logic is in `lib/` and `src/`, with each platform handled by a dedicated file (e.g., `sendAPN.js`, `sendFCM.js`).
6+
7+
**Note:** Legacy GCM (Google Cloud Messaging) support has been removed. All Android push notifications now route exclusively through Firebase Cloud Messaging (FCM).
68

79
## Architecture & Data Flow
810

@@ -21,29 +23,31 @@ This repository implements a Node.js module for sending push notifications acros
2123

2224
## Conventions & Patterns
2325

24-
- **Platform-specific files:** Each push service has its own file for isolation and clarity.
26+
- **Platform-specific files:** Each push service has its own file for isolation and clarity. Legacy GCM is no longer supported.
2527
- **Unified Data Model:** The `data` object for notifications is normalized across platforms. See `README.md` for all supported fields.
2628
- **Error Handling:** Errors are unified and returned in the result array from `push.send`.
2729
- **RegId Format:** Prefer object format for registration IDs (`{id, type}`), but string format is supported for legacy reasons.
28-
- **Chunking:** Android tokens are chunked in batches of 1,000 automatically.
29-
- **Constants:** Use constants from `constants.js` for platform types.
30+
- **Android Routing:** All Android push notifications (both long regIds and ADM/AMZN tokens without explicit type) route through FCM.
31+
- **Chunking:** Android tokens are chunked in batches of 1,000 automatically by FCM.
32+
- **Constants:** Use constants from `constants.js` for platform types. Available constants: `FCM_METHOD`, `APN_METHOD`, `WNS_METHOD`, `ADM_METHOD`, `WEB_METHOD`, `UNKNOWN_METHOD`.
3033

3134
## Integration Points
3235

3336
- **External Libraries:**
34-
- APN: `node-apn`
35-
- FCM: `firebase-admin`
36-
- GCM: `node-gcm`
37+
- APN: `@parse/node-apn`
38+
- FCM: `firebase-admin` (all Android push notifications)
3739
- ADM: `node-adm`
3840
- WNS: `wns`
3941
- Web-Push: `web-push`
42+
- Note: Legacy `node-gcm` library has been removed
4043
- **Credentials:** Place service account keys and certificates in appropriate locations (see `README.md` for examples).
4144

4245
## Key Files & Directories
4346

44-
- `lib/` and `src/`: Main implementation (mirrored structure)
45-
- `test/`: Test cases and sample credentials
47+
- `lib/` and `src/`: Main implementation (mirrored structure, both CommonJS)
48+
- `test/`: Test cases (78 tests, all passing) and sample credentials
4649
- `README.md`: Usage, configuration, and data model reference
50+
- `.github/copilot-instructions.md`: This file - AI agent guidance
4751

4852
## Example Usage
4953

README.md

Lines changed: 45 additions & 208 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 10 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"@parse/node-apn": "7.0.1",
5555
"firebase-admin": "12.1.1",
5656
"node-adm": "0.9.1",
57-
"node-gcm": "1.1.4",
5857
"web-push": "3.6.7",
5958
"wns": "0.5.4"
6059
},

src/constants.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module.exports = {
22
DEFAULT_TTL: 28 * 86400,
33
GCM_MAX_TTL: 2419200, // 4 weeks in seconds (https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json)
44
APN_METHOD: "apn",
5-
GCM_METHOD: "gcm",
65
FCM_METHOD: "fcm",
76
ADM_METHOD: "adm",
87
WNS_METHOD: "wns",
@@ -71,6 +70,5 @@ module.exports = {
7170
// contentEncoding: '< Encoding type, e.g.: aesgcm or aes128gcm >'
7271
},
7372
isAlwaysUseFCM: false,
74-
isLegacyGCM: false,
7573
},
7674
};

src/push-notifications.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const sendGCM = require("./sendGCM");
21
const sendFCM = require("./sendFCM");
32
const APN = require("./sendAPN");
43
const sendADM = require("./sendADM");
@@ -11,7 +10,6 @@ const {
1110
WEB_METHOD,
1211
WNS_METHOD,
1312
ADM_METHOD,
14-
GCM_METHOD,
1513
FCM_METHOD,
1614
APN_METHOD,
1715
} = require("./constants");
@@ -27,7 +25,6 @@ class PN {
2725
this.apn.shutdown();
2826
}
2927
this.apn = new APN(this.settings.apn);
30-
this.useFcmOrGcmMethod = this.settings.isLegacyGCM ? GCM_METHOD : FCM_METHOD;
3128
}
3229

3330
sendWith(method, regIds, data, cb) {
@@ -50,14 +47,14 @@ class PN {
5047
if (typeof regId === "object" && regId.id && regId.type) {
5148
return {
5249
regId: regId.id,
53-
pushMethod: this.settings.isAlwaysUseFCM ? this.useFcmOrGcmMethod : regId.type,
50+
pushMethod: this.settings.isAlwaysUseFCM ? FCM_METHOD : regId.type,
5451
};
5552
}
5653

5754
// TODO: deprecated, remove of all cases below in v3.0
5855
// and review test cases
5956
if (this.settings.isAlwaysUseFCM) {
60-
return { regId, pushMethod: this.useFcmOrGcmMethod };
57+
return { regId, pushMethod: FCM_METHOD };
6158
}
6259

6360
if (regId.substring(0, 4) === "http") {
@@ -73,15 +70,14 @@ class PN {
7370
}
7471

7572
if (regId.length > 64) {
76-
return { regId, pushMethod: this.useFcmOrGcmMethod };
73+
return { regId, pushMethod: FCM_METHOD };
7774
}
7875

7976
return { regId, pushMethod: UNKNOWN_METHOD };
8077
}
8178

8279
send(_regIds, data, callback) {
8380
const promises = [];
84-
const regIdsGCM = [];
8581
const regIdsFCM = [];
8682
const regIdsAPN = [];
8783
const regIdsWNS = [];
@@ -96,8 +92,6 @@ class PN {
9692

9793
if (pushMethod === WEB_METHOD) {
9894
regIdsWebPush.push(regId);
99-
} else if (pushMethod === GCM_METHOD) {
100-
regIdsGCM.push(regId);
10195
} else if (pushMethod === FCM_METHOD) {
10296
regIdsFCM.push(regId);
10397
} else if (pushMethod === WNS_METHOD) {
@@ -112,11 +106,6 @@ class PN {
112106
});
113107

114108
try {
115-
// Android GCM / FCM (Android/iOS) Legacy
116-
if (regIdsGCM.length > 0) {
117-
promises.push(this.sendWith(sendGCM, regIdsGCM, data));
118-
}
119-
120109
// FCM (Android/iOS)
121110
if (regIdsFCM.length > 0) {
122111
promises.push(this.sendWith(sendFCM, regIdsFCM, data));
@@ -192,5 +181,4 @@ module.exports = PN;
192181
module.exports.WEB = WEB_METHOD;
193182
module.exports.WNS = WNS_METHOD;
194183
module.exports.ADM = ADM_METHOD;
195-
module.exports.GCM = GCM_METHOD;
196184
module.exports.APN = APN_METHOD;

0 commit comments

Comments
 (0)