https://github.com/thre4dripper/fcm-notification-service
This Appwite Function as a service is one shot solution for FCM notifications
https://github.com/thre4dripper/fcm-notification-service
Last synced: 2 months ago
JSON representation
This Appwite Function as a service is one shot solution for FCM notifications
- Host: GitHub
- URL: https://github.com/thre4dripper/fcm-notification-service
- Owner: Thre4dripper
- Created: 2024-12-07T10:20:11.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-12-07T13:19:00.000Z (6 months ago)
- Last Synced: 2025-02-10T04:29:26.446Z (4 months ago)
- Language: TypeScript
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🔔 Node.js Push Notifications with FCM Function
Send push notifications to your users using Firebase Cloud Messaging (FCM).
## 🧰 Usage
### POST /
Send a push notification to a user.
**Parameters**
| Name | Description | Location | Type | Sample Value |
| ------------ | ------------------------------------ | -------- | ------------------ | ---------------------- |
| Content-Type | The content type of the request body | Header | `application/json` | N/A |
| deviceToken | FCM device identifier | Body | String | `642...7cd` |
| data | Additional data to pass | Body | Object | `{"greet": "welcome"}` |**Request**
`deviceToken` and `message` are required. `data` is optional.
```json
{
"deviceToken": "642...7cd",
"data": {
"greet": "welcome"
}
}
```**Response**
Sample `200` Response:
```json
{
"ok": true,
"messageId": "as4jg109cbe1"
}
```Sample `400` Response:
```json
{
"ok": false,
"error": "Device token and message are required."
}
```Sample `500` Response:
```json
{
"ok": false,
"error": "Failed to send the message."
}
```## ⚙️ Configuration
| Setting | Value |
| ----------------- | ------------- |
| Runtime | Node (18.0) |
| Entrypoint | `src/main.js` |
| Build Commands | `npm install` |
| Permissions | `any` |
| Timeout (Seconds) | 15 |## 🔒 Environment Variables
### FCM_PROJECT_ID
A unique identifier for your FCM project.
| Question | Answer |
| ------------- | ---------------------------------------------------------------------------------- |
| Required | Yes |
| Sample Value | `mywebapp-f6e57` |
| Documentation | [FCM: Project ID](https://firebase.google.com/docs/projects/learn-more#project-id) |### FCM_CLIENT_EMAIL
Your FCM service account email.
| Question | Answer |
| ------------- | ------------------------------------------------------------------------------------------------------------ |
| Required | Yes |
| Sample Value | `[email protected]` |
| Documentation | [FCM: SDK Setup](https://firebase.google.com/docs/admin/setup#initialize_the_sdk_in_non-google_environments) |### FCM_PRIVATE_KEY
A unique private key used to authenticate with FCM.
| Question | Answer |
| ------------- | ------------------------------------------------------------------------------------------------------------ |
| Required | Yes |
| Sample Value | `0b6830cc66d92804e11af2153242d34211d675675` |
| Documentation | [FCM: SDK Setup](https://firebase.google.com/docs/admin/setup#initialize_the_sdk_in_non-google_environments) |