Ionic framework 爱奥尼亚:我如何使应用程序永远不会退出,而是在后台工作,或者我如何在应用程序退出时调用函数?
我正在使用IONIC构建一个应用程序。我用的是cordova背景模式软件包。我设法使它在后台工作,当显示器打开等。我也使用电源管理软件包从科尔多瓦。 我在app.component文件中的代码如下所示:Ionic framework 爱奥尼亚:我如何使应用程序永远不会退出,而是在后台工作,或者我如何在应用程序退出时调用函数?,ionic-framework,ionic4,Ionic Framework,Ionic4,我正在使用IONIC构建一个应用程序。我用的是cordova背景模式软件包。我设法使它在后台工作,当显示器打开等。我也使用电源管理软件包从科尔多瓦。 我在app.component文件中的代码如下所示: initializeApp() { this.platform.ready().then(() => { this.statusBar.styleDefault(); this.splashScreen.hide(); this.st
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
this.statusBar.overlaysWebView(true);
this.statusBar.isVisible = true;
this.statusBar.show();
this.backgroundMode.enable();
this.powerManagement.acquire()
.then(() => {
})
.catch(() => {
});
});
}
在我的AndroidManifest.xml中,我使用的代码如下:
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
但当我从“打开的应用程序”列表中关闭应用程序时,它会终止应用程序,并且不会继续在后台运行。
我该怎么办?查看Github文档:也许你忘了什么不,我什么都没忘。我从他们的文档中尝试了一切