This project forked from CostianuRazvan/nestjs-fcm
npm install --save @doracoder/fcm-nestjs
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 { 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 {}
@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,
);
}
}
See Changelog for more information.
Contributions welcome! See Contributing.
Tran Quy
Licensed under the MIT License - see the LICENSE file for details.