0.1.4 • Published 2 years ago
nestjs-push v0.1.4
Installation
npm install --save nestjs-push
FcmModule
To use PushService you must add the module first.
The PushModule
has a @Global()
attribute so you should only import it once.
import { Module } from '@nestjs/common';
import * as path from 'path';
import { PushModule } from 'nestjs-push';
@Module({
imports: [
PushModule.forRoot({
serviceJsonPath: path.join(__dirname, '../service-account.json'),
}),
],
controllers: [],
})
export class AppModule {}
PushService
use service-account-json.json file to send notifications using firebase-admin dependency.
@Injectable()
export class SampleService {
constructor(private readonly pushService: PushService) {}
async doStuff() {
await this.pushService.sendToDevices([
'device_token_1',
'device_token_1',
],
payload,
imageUrl,
]);
await this.pushService.sendToTopics(
'topic-name',
payload,
imageUrl,
]);
}
}
Change Log
See Changelog for more information.
Contributing
Contributions welcome! See Contributing.
Author
Irvan Setiawan
License
Licensed under the MIT License - see the LICENSE file for details.