Ionic 3/4如何停止从最近的应用程序刷卡时杀死应用程序? [英] Ionic 3/4 How to stop app kill on swiping from recent apps?

查看:86
本文介绍了Ionic 3/4如何停止从最近的应用程序刷卡时杀死应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于ionic4/cordova构建应用程序的项目,该应用程序始终在后台运行.它基本上是每小时在后台或前台将数据发送到服务器.

I have a project to build an app based on ionic4/ cordova, running in the background all the time. It basically sends data to server every hour when in the background or foreground.

但是,当应用程序用户在最近的应用程序中向右滑动时,该应用程序将被杀死.我进行了很多搜索,并要求各种人员和文档提供帮助,但到目前为止还没有任何线索.

But the app gets killed when the app user swipes it right in the recent apps. I have searched a lot and asked help from various people and documentations, but haven't got any clue till now.

我是Ionic的新手,请提出一些帮助,如何解决此问题?

I am new to Ionic, please suggest some help, how to deal with this problem?

  • 提前感谢:)

推荐答案

我想您是在要求它进行android构建,因此一些android制造商会在我们向上或向右滑动(按移动功能)时杀死该应用程序延长电池寿命,因此有三种方法可以在后台运行您的应用程序

I suppose you are asking it for android build ,so some of the android manufacturer are killed the app while we swipe up or right (as per mobile feature) to improve battery life,so there is three way to run your app in background

1)一种明显的离子方式是使用自动启动本机插件,该插件已在自动启动,您可以在app.component.ts文件中使用它,因此此插件会在一段时间内自动唤醒您的应用

1)one is obviously ionic way is to use autostart native plugin which has been explain it briefly to ionic documents of autostart you can use it in app.component.ts file so this plugin is automatically wake up your app on some time period

2)第二步是手动操作,只需转到转到设置" >>电池" >>电池优化"并启用自动启动(适用于oneplus android),所有制造商都有自己的设置来启用和禁用自动启动权限,因此将其搜索为根据您的模型.

2)second is to do manual way just go to your Goto Settings >> Battery >> Battery Optimization and enable autolaud (for oneplus android) all the manufacturer has there own setting to enable and disable auto start permission so search it as per your model.

3)在清单文件中,将Service的标志stopWithTask保持为 false .根据此android权限

3)Inside your Manifest file, keep flag stopWithTask as false for Service.As per this android permission link

manifest.xml

manifest.xml

<service
    android:name="com.myapp.MyService"
    android:stopWithTask="false" />

谢谢

这篇关于Ionic 3/4如何停止从最近的应用程序刷卡时杀死应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆