https://github.com/tranphuquy19/fcm-nestjs
Firebase Cloud Message module for NestJS
https://github.com/tranphuquy19/fcm-nestjs
firebase nest nestjs nodejs typescript
Last synced: over 1 year ago
JSON representation
Firebase Cloud Message module for NestJS
- Host: GitHub
- URL: https://github.com/tranphuquy19/fcm-nestjs
- Owner: tranphuquy19
- License: mit
- Created: 2021-07-15T22:13:32.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-21T07:32:47.000Z (over 3 years ago)
- Last Synced: 2025-02-28T06:55:15.766Z (over 1 year ago)
- Topics: firebase, nest, nestjs, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 343 KB
- Stars: 13
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
NestJS FCM push notifications module
_This project forked from [CostianuRazvan/nestjs-fcm](https://github.com/CostianuRazvan/nestjs-fcm)_
### Installation
```bash
npm install --save @doracoder/fcm-nestjs
```
### FcmModule
To user FcmService you must add the module first. **The `FcmModule` has a `@Global()` attribute so you should only import it once**.
```typescript
import { Module } from '@nestjs/common';
import { FcmModule } from '@doracoder/fcm-nestjs';
import * as path from 'path';
@Module({
imports: [
FcmModule.forRoot({
firebaseSpecsPath: path.join(__dirname, '../firebase.spec.json'),
}),
],
controllers: [],
})
export class AppModule {}
```
### `FcmService` use firebase.spec.json file to send notifications using firebase-admin dependency.
```typescript
@Injectable()
export class SampleService {
constructor(private readonly fcmService: FcmService) {}
async sendToDevices() {
await this.fcmService.sendNotification([
'device_token_1',
'device_token_2',
]
payload,
silent,
);
}
async sendToTopic(topic: string) {
await this.fcmService.sendToTopic(
topic,
payload,
silent,
);
}
}
```
## Change Log
See [Changelog](CHANGELOG.md) for more information.
## Contributing
Contributions welcome! See [Contributing](CONTRIBUTING.md).
## Author
**Tran Quy**
## License
Licensed under the MIT License - see the [LICENSE](LICENSE) file for details.