import { Injectable } from '@angular/core'; import { Platform } from '@ionic/angular'; import { CapacitorConfig } from '@capacitor/cli'; import { LocalNotifications, LocalNotificationSchema } from '@capacitor/local-notifications'; @Injectable({ providedIn: 'root' }) export class NativeNotificationService { constructor(private platform: Platform,) { this.askForPermission() } askForPermission() { LocalNotifications.requestPermissions() LocalNotifications.checkPermissions().then((data)=>{ // }).catch((data)=>{ // }) } foregroundNotification() { console.log('Local notification foreground') LocalNotifications.addListener('localNotificationReceived', (notification) => { console.log('Local Notification',notification) }) } sendNotificationChat({title = 'User', icon = '', message = 'hello'}) { LocalNotifications.schedule({ notifications:[ { title : title, body : message, id : new Date().getTime() } ] }); } isDesktop() { if (this.platform.is('desktop') || this.platform.is('mobileweb')) { return true } else { return false } } }