Ionic 3/4 How to stop app kill on swiping from recent apps?

限于喜欢 提交于 2020-01-06 07:53:59

问题


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.

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

  • thanks in advance :)

回答1:


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)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)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)Inside your Manifest file, keep flag stopWithTask as false for Service.As per this android permission link

manifest.xml

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

Thank you,



来源:https://stackoverflow.com/questions/54778793/ionic-3-4-how-to-stop-app-kill-on-swiping-from-recent-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!