Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make entire ionic android app to run as background service?

I am currently developing a todo app (android) using ionic framework which can synchronize with the pouchdb when it is connected to the internet, and also user will receive notification in background when new task has been added to the database and sync to the phone.

So if I want the user to receive the notification in background the whole app should be also running in background so that it will detect any new task sync to the phone and generate local notification to notify the user about the incoming new task.

So my question is: is it possible to make my whole cordova/ionic app or whole app.js to be running in background as a background service?

like image 660
Eric Hooi Avatar asked Feb 18 '16 01:02

Eric Hooi


People also ask

How do you create an Ionic background service?

Create a Service (Right click on app folder, new-->Service in Android Studio) inside the folder where MainActivity is present. Give the same package name of MainActivity at top of the new file. Then put the service code and instructions by how to work.

How do I run an Ionic app on my real Android phone?

To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run ionic cordova run android --device from the command line. Enabling USB debugging and Developer Mode can vary between devices, but is easy to look up with a Google search.


1 Answers

You can try to use this plugin:

https://github.com/MobileChromeApps/cordova-plugin-background-app

eventually, if you need, in conjunction with:

  • cordova-plugin-background-mode to manage background mode and simple notifications
  • cordova-toforeground to force the to come back on foreground
like image 50
beaver Avatar answered Sep 21 '22 14:09

beaver