import { Injectable } from '@angular/core'; import { NavController, ToastController } from 'ionic-angular'; declare function io(url: string): any; @Injectable() export class ServerNotificationProvider { socket: any; constructor( public toastctrl: ToastController ) { } notify(nav: NavController, server: string) { this.socket = io(server); this.socket.on('notify', function(msg: string) { const toast = this.toastctrl.create({ message: msg, duration: 2000 }); toast.present(); }); } }