Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 19 days 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 (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-21T07:32:47.000Z (over 1 year ago)
- Last Synced: 2024-10-15T22:33:34.454Z (about 1 month ago)
- Topics: firebase, nest, nestjs, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 343 KB
- Stars: 13
- Watchers: 1
- Forks: 4
- 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.