import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { CommonProvider } from '../../providers/common/common';
import { Storage } from '@ionic/storage';

/**
 * Generated class for the NotificationPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-notification',
  templateUrl: 'notification.html',
})
export class NotificationPage {
	token:any;
	result:any;

  constructor(public navCtrl: NavController, public navParams: NavParams, public service: CommonProvider,public storage: Storage) {
  		//var post_data = [];
	  	this.storage.get('token').then(data => {
	  		if(data && data!=undefined){
	  			var post_data = {'token':data};
	  			var This = this;
	  			this.service.show_loader(); 
	  			var timer = setInterval(function(){
	  				console.log(post_data);
	  				if(data!=''){
	  					clearInterval(timer);
	  					This.service.post_data('notify_list',post_data).subscribe(data=>{
				    		This.result = data.result;
				       	 	This.service.hide_loader();
				    		//console.log(data);
				    	})
	  				}			    	
			    },100);
	  		}  	
		})
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad NotificationPage');
  }

}
