You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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) using the Firebase Admin SDK.
6
8
7
9
## Architecture & Data Flow
8
10
@@ -14,40 +16,187 @@ This repository implements a Node.js module for sending push notifications acros
14
16
15
17
## Developer Workflows
16
18
17
-
-**Install:**`npm install`
18
-
-**Test:** Run all tests with `npm test`. Tests are in `test/` and cover basic flows and platform-specific cases.
19
+
-**Install:**`npm install` (requires Node.js 18+)
20
+
-**Test:** Run all tests with `npm test`. Tests are in `test/` and cover basic flows and platform-specific cases (87 tests, all passing).
19
21
-**Debug:** Use the callback or Promise error/result from `push.send`. Each result object includes method, success/failure counts, and error details per device.
20
22
-**Build:** No build step required for basic usage. ES6 is used, but compatible with ES5 via Babel if needed.
21
23
22
24
## Conventions & Patterns
23
25
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.
25
27
-**Unified Data Model:** The `data` object for notifications is normalized across platforms. See `README.md` for all supported fields.
26
28
-**Error Handling:** Errors are unified and returned in the result array from `push.send`.
27
29
-**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 route through FCM using Firebase Admin SDK.
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`.
33
+
34
+
## Firebase Cloud Messaging (FCM) - Modern Implementation
35
+
36
+
### Message Building (src/utils/tools.js)
37
+
38
+
**buildAndroidMessage(data, options)**
39
+
- Converts unified notification data to Firebase Admin SDK AndroidMessage format
40
+
- Returns plain JavaScript object (no wrapper functions)
41
+
- Properties mapped to camelCase (Firebase SDK standard)
42
+
- Removes undefined values for clean API calls
43
+
- Converts TTL from seconds to milliseconds
44
+
- Supports all 20+ AndroidNotification properties
45
+
46
+
**buildAndroidNotification(data)**
47
+
- Maps input `data` object to AndroidNotification interface
0 commit comments