android - How to prevent the app from getting paused when killed in ionic 2 -


i have app in function called every minute (calling function every minute done through setinterval method).i have implemented local notificaiton inside function.so after every minute call function , show notification.i able see notification after every minute , happens when app running or when minimized ,but when close app function not getting called. i've used background mode plugin not working when app killed or cleared.

code :

import { component } '@angular/core'; import { navcontroller } 'ionic-angular'; import { localnotifications } '@ionic-native/local-notifications'; import {backgroundmode} '@ionic-native/background-mode'; import {http,requestoptions,headers} '@angular/http' @component({   selector: 'page-home',   templateurl: 'home.html' }) export class homepage {    count:any; content= "yashwanth"   constructor(public navctrl: navcontroller,public http: http,public backgroundmode: backgroundmode,private localnotifications: localnotifications) {   this.backgroundmode.enable();   } a(){    let body:string ="&a=aksjd",     url:any = "http://some_site_name/abc.php",         type : string   = "application/x-www-form-urlencoded; charset=utf-8",     headers  :      = new headers({ 'content-type': type}),     options  :      = new requestoptions({ headers: headers });      this.http.post(url,body,options).subscribe((data) => {       let = json.parse(data['_body']);       this.count = a['count'];     console.log(this.count);          this.localnotifications.schedule({   id: 1,   text: 'the count of ' + this.content + this.count  });      }); setinterval(()=>this.a(),60000); }  ionviewdidload(){ this.a(); }  } 


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -