La Reyna
La Reyna

Reputation: 138

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

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?

Upvotes: 0

Views: 1974

Answers (1)

Aniruddh Thakor
Aniruddh Thakor

Reputation: 1616

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,

Upvotes: 1

Related Questions