Push notifications with capacitor runing great

This commit is contained in:
Eudes Inácio
2021-11-05 07:49:01 +01:00
parent 84f2c1cc36
commit 1d58ef0615
12 changed files with 200 additions and 131 deletions
+14 -13
View File
@@ -2,8 +2,8 @@
/* tslint:disable */
import { Component, OnInit, NgZone } from '@angular/core';
import { Event } from '../models/event.model';
/* import { NotificationsService } from '../services/notifications.service';
import { WebNotificationsService } from '../services/webnotifications.service'; */
import { NotificationsService } from '../services/notifications.service';
/*import { WebNotificationsService } from '../services/webnotifications.service'; */
import { AlertController, Platform } from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router';
import { ToDayEventStorage } from '../store/to-day-event-storage.service';
@@ -14,7 +14,7 @@ import { InativityService } from '../services/inativity.service';
import { SessionStore } from '../store/session.service';
import { StorageService } from '../services/storage.service';
import { File } from '@ionic-native/file/ngx';
import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service';
/* import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service'; */
import { DocumentCounterService } from '../services/worker/document-counter.service';
import { PermissionService } from '../services/worker/permission.service';
import { Network } from '@ionic-native/network/ngx';
@@ -24,7 +24,6 @@ import { Storage } from '@ionic/storage';
import { EventsService } from 'src/app/services/events.service';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
@Component({
selector: 'app-home',
templateUrl: './home.page.html',
@@ -70,7 +69,7 @@ export class HomePage implements OnInit {
private zone: NgZone,
private router: Router,
public modalCtrl: AlertController,
/* private notificationsService: NotificationsService, */
private notificationsService: NotificationsService,
private platform: Platform,
private activeroute: ActivatedRoute,
/* private webnotification: WebNotificationsService, */
@@ -79,14 +78,14 @@ export class HomePage implements OnInit {
private despachoRule: DespachoService,
private inativityService: InativityService,
private storageService: StorageService,
private webNotificationPopupService: WebNotificationPopupService,
/* private webNotificationPopupService: WebNotificationPopupService, */
private backgroundservice: BackgroundService,
private offlinemanager: OfflineManagerService,
private storage: Storage,
private eventservice: EventsService,
private screenOrientation: ScreenOrientation,) {
this.webNotificationPopupService.askNotificationPermission()
/* this.webNotificationPopupService.askNotificationPermission() */
this.router.events.subscribe((val) => {
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
@@ -114,6 +113,8 @@ export class HomePage implements OnInit {
ngOnInit() {
this.notificationsService.onReciveForeground();
this.notificationsService.onReciveBackground();
window.addEventListener('online', () => {
console.log('Became online')
@@ -143,12 +144,12 @@ export class HomePage implements OnInit {
updateList() {
/* this.notificationsService.registerCallback(
'despachos',
() => {
this.despachoRule.getList({ updateStore: true })
}
) */
/* this.notificationsService.registerCallback(
'despachos',
() => {
this.despachoRule.getList({ updateStore: true })
}
) */
document.addEventListener('pause', function () {
// console.log('App going to background');