import { Injectable } from '@angular/core' ; import { ToastController } from 'ionic-angular' ; @ Injectable ( ) export class NotificationService { /**
     * The amount of time to show a toast (in milliseconds)
     */ private time_show_time : number = 3000 ; /**
     * The position of the toast
     */ private toast_position : string = 'bottom' ; /**
     * The close toast button text
     */ private toast_close_text : string = 'Close' ; /**
     * A flag that decides whether to show the toast close button
     */ private show_toast_close_button : boolean = true ; constructor ( private toast_controller ) { } param message public notify_error ( error , details ? ) { console . log ( error , details ) ; let toast = this . toast_controller . create ( { message : 'Something went wrong. Try again later' , duration : this . time_show_time , position : this . toast_position , showCloseButton : this . show_toast_close_button , closeButtonText : this . toast_close_text , cssClass : 'toast-danger' } ) ; toast . present ( ) ; } param message public notify_info ( message ) { let toast = this . toast_controller . create ( { message : message , duration : this . time_show_time , position : this . toast_position , showCloseButton : this . show_toast_close_button , closeButtonText : this . toast_close_text , cssClass : 'toast-info' } ) ; toast . present ( ) ; } param message public notify_warning ( message ) { let toast = this . toast_controller . create ( { message : message , duration : this . time_show_time , position : this . toast_position , showCloseButton : this . show_toast_close_button , closeButtonText : this . toast_close_text , cssClass : 'toast-warning' } ) ; toast . present ( ) ; } param message public notify_success ( message ) { let toast = this . toast_controller . create ( { message : message , duration : this . time_show_time , position : this . toast_position , showCloseButton : this . show_toast_close_button , closeButtonText : this . toast_close_text , cssClass : 'toast-success' } ) ; toast . present ( ) ; } }