From 1b7146b92df7c2ccf41761dfd155af11f89ceb59 Mon Sep 17 00:00:00 2001 From: Ben Goldsworthy Date: Sun, 8 Nov 2020 17:38:49 +0000 Subject: [PATCH] Integrate service with app --- src/app/app.component.ts | 14 +++++++++++++- src/app/app.module.ts | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 94160ad..a8ded8b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,7 +1,19 @@ import { Component } from '@angular/core'; +import { MessagingService } from './service/messaging.service'; @Component({ selector: 'app-root', template: '' }) -export class AppComponent { } +export class AppComponent { + title = 'push-notification'; + message; + + constructor(private messagingService: MessagingService) { } + + ngOnInit() { + this.messagingService.requestPermission(); + this.messagingService.receiveMessage(); + this.message = this.messagingService.currentMessage; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 067c810..3ded6fc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -23,6 +23,11 @@ import { OrgGuard } from './_guards/org.guard'; import { CustomerGuard } from './_guards/customer.guard'; import { ApiService } from './providers/api-service'; +import { AngularFireMessagingModule } from '@angular/fire/messaging'; +import { AngularFireModule } from '@angular/fire'; +import { MessagingService } from './service/messaging.service'; +import { AsyncPipe } from '../../node_modules/@angular/common'; + import { OrgGraphsService } from './providers/org-graphs.service'; import { CustGraphsService } from './providers/cust-graphs.service'; import { OrgSnippetsService } from './providers/org-snippets.service'; @@ -51,6 +56,8 @@ import { FilterPipeModule } from 'ngx-filter-pipe'; BrowserModule, HttpClientModule, FormsModule, + AngularFireMessagingModule, + AngularFireModule.initializeApp(environment.firebase), FilterPipeModule, ReactiveFormsModule, NgxPaginationModule, @@ -76,6 +83,8 @@ import { FilterPipeModule } from 'ngx-filter-pipe'; ], providers: [ AuthGuard, + MessagingService, + AsyncPipe, OrgGuard, CustomerGuard, ApiService, @@ -92,6 +101,7 @@ import { FilterPipeModule } from 'ngx-filter-pipe'; ], bootstrap: [ AppComponent ] }) + export class AppModule { constructor () { if (environment.enableAnalytics) {