Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service and cordova plugin

I would like to know what is the best way to solve my problem. And my problem is the following.

I have developed an android app using cordova. The native android code is the minimum required.

What I need is, when the app starts, to start a service with it. When the app closes the service must be remain running. The service communicates with a server and downloads something if this "something" exists. Only after download event the service must notify the user to start the initial app and see the results or, even better, the service itself to start the initial app.

What is the best way to implement this, taking into account that I don't want to discard my app in cordova.

I've examined the plugin creation since the most code of the original app and the service code is the same. Is a cordova plugin the best way to implement my service? Can a cordova plugin service my purpose or I am totally wrong?

Is it possible to use my javascript code in this plugin?

Do I need to pass to native code in order to accomplish what I need?

Thank you in advance

George

like image 522
gbarel Avatar asked Nov 01 '22 05:11

gbarel


1 Answers

As far as I tried it out the cordova android plugin runs while the app is running. After it is closed, it stops.

But there is a plugin available which brings background serivce support. https://github.com/Red-Folder/bgs-core

http://red-folder.blogspot.de/

The Java background service runs on, even if the app is closed but does no longer provide JavaScript event handlings. All your background service code you want to use even if the app is closed, has to be written in native android Java.

like image 173
Lukas Bernhard Avatar answered Nov 11 '22 04:11

Lukas Bernhard