如何使应用程序在后台模式下运行

时间:2018-09-24 15:17:26

标签: ionic3

我已经构建了离子应用程序,并且我需要一种方法来保持应用程序在后台运行, 我使用设置间隔来发送HTTP请求,但是当我关闭应用程序时

  constructor(
              public http: HttpClient,
              public platform: Platform ,
              public navCtrl: NavController, 
              private callLog: CallLog,
              private backgroundMode: BackgroundMode,
              private statusBar : StatusBar,
              private appService: AppServiceProvider,
              private uniqueDeviceID: UniqueDeviceID,
            ) 
          {
            var self= this
            if(this.platform.is('cordova')){
              this.platform.ready().then(()=>{
              this.getDeviceId()
              this.deviceId = localStorage.getItem('DviceId')
              this.callLog.requestReadPermission()
              this.backgroundMode.enable();
              this.statusBar.overlaysWebView(true);
              this.statusBar.styleDefault();
              setInterval(function(){
                self.backgroundMode.enable()
                self.postLogs()
              }, 6000)
            })
          }
          }

0 个答案:

没有答案