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)
})
}
}
解决方案
推荐阅读
- php - 如何解决从联系表发送电子邮件的错误
- python - 将字符串列表转换为指定格式的原始 python 列表
- git - 涉及两个帐户的github repo问题
- javascript - 如何使 Canvas 绘图持久化?
- python-3.x - 不支持 Facebook Graph API 版本
- python - 循环将范围(0,10)标准化为(0,1)
- project-reactor - 有什么方法可以检测或阻止 Flux 或 Mono 的多个订阅者?
- python - PIL 转换为 CMYK 不设置 K 分量
- laravel - Laravel 具有多列的枢轴
- mql5 - 我如何定义与图表符号相关的文件名称?