import { Injectable } from '@angular/core' ; import { ElectronService } from 'ngx-electron' ; @ Injectable ( { providedIn : 'root' } ) export class AppService { constructor ( private electronService ) { } public isDesktop ( ) { return this . electronService . isElectronApp ; } public showDesktopMessage ( title , body ) { if ( ! this . electronService . isElectronApp ) { return ; } new window . Notification ( title , { body , title : 'Phoenix' } ) ; } public openInBrowser ( url ) { if ( ! this . electronService . isElectronApp ) { console . log ( 'Opening url:' , url ) ; return ; } return this . electronService . shell . openExternal ( url ) ; } public onIpcMessage ( eventName , handler ) { if ( ! this . electronService . isElectronApp ) { return ; } this . electronService . ipcRenderer . on ( eventName , ( event , data ) => { handler ( data ) ; } ) ; } public sendIpcMessage ( eventName , payload ) { if ( ! this . electronService . isElectronApp ) { return ; } this . electronService . ipcRenderer . send ( eventName , payload ) ; } }