Skip to content

costianur95/nestjs-fcm

Repository files navigation

NestJS FCM push notifications module

Installation

npm install --save nestjs-fcm

FcmModule

To user FcmService you must add the module first. The FcmModule has a @Global() attribute so you should only import it once.

import { Module } from '@nestjs/common';
import * as path from 'path';
import { FcmModule } from 'nestjs-fcm';

@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.

@Injectable()
export class SampleService {
  constructor(private readonly fcmService: FcmService) {}

  async doStuff() {
    await this.fcmService.sendNotification([
      'device_id_1',
      'device_id_2',
      ]
      payload,
      silent,
    ]);
  }
}

Change Log

See Changelog for more information.

Contributing

Contributions welcome! See Contributing.

Author

Razvan Costianu

License

Licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published