JimmyH
Posts: 0
Joined: Sun Jan 25, 2015 5:01 am

How to install the cordova-plugin-background-mode plugin

I have been trying to sort this problem out for ages (I am a beginner).

I want to run javascript when the app is in the background. I have tried setinterval but this dies after a while (10mins) when the app goes into the background mode.

So I thought I need a service to run in the background which then calls the javascript. I found katzer/cordova-plugin-background-mode plugin (https://github.com/katzer/cordova-plu...).

This looked to be able to run js in the background. (it would be great if somebody could confirm this for me).

I then needed to add the plugin in my app. Below I have described the steps that I have followed, though it does not work.

Please help!.

I hope that this thread will help other appery users install 3rd party plugins as there is not much information on it.

  1. I downloaded the plugin zip and then opened the BackgroundMode.java file. From here I used the following information to set up the up the following folder structure in appery source.

    Image

    So it looked like this:

    Image

  2. In the www folder, I uploaded the file background-mode.js

  3. I then edited the background-mode.js file and inserted the following at the start of the file.

    Image

    I was not sure about the last part (ie .BackgroundMode). This was used as I checked the cordova-plugin-background-mode plugin.xml file (below) and the name was BackgroundMode.

    Image

  4. I then added }); to the end of the script in background-mode.js (see below).

    Image

    All good so far?

  5. I then edited the cordova_plugin .js file (in the lib folder) and added the following.
    ,
    {
    "file": "plugins/de.appplant.cordova.plugin.background/www/background-mode.js",
    "id": "de.appplant.cordova.plugin.background.backgroundMode",
    "clobbers": [
    "backgroundMode"
    ]
    }
    So it looked like this.

    Image

    The information used here was sourced from the cordova-plugin-background-mode plugin.xml (see below)

    Image

    6a. I then went to res xml config.xml and added the following code:

    To the start of the file so that it looked like this:

    Image

    6b. and at the end of the file I added the following:

    Code: Select all

     param name="android-package" value="de.appplant.cordova.plugin.localnotification.LocalNotification"  
    
     param name="android-package" value="de.appplant.cordova.plugin.background.BackgroundMode"  

So it looked like:

Image

The information required for step 6 was sourced from the cordova-plugin-background-mode plugin.xml file (see below).
Image

  1. I then created the following folder structure and uploaded the following files from the zip that I downloaded.
    Image

  2. I then went to AndroidManifest.xml. and added the following:

    I was not sure where I should put it so I did it under the only other service in the file.
    So it looked like this:

    Image

    This information was sourced from the plugin.xml file (see below)

    Image

    The app compiled OK with no errors. I installed the app and tried to call the javascript at a time in the future. Unfortunately it did not work. When I checked my device to see which apps were running in the background, my app wasn’t showing.

    Any help would be greatly appreciated.
    Jimmy

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to install the cordova-plugin-background-mode plugin

Hello Jimmy,

Unfortunately plugins are outside the scope of our support, but I hope someone of the users faced this problem and would help you.

JimmyH
Posts: 0
Joined: Sun Jan 25, 2015 5:01 am

How to install the cordova-plugin-background-mode plugin

Hi Evgene,

Is it possible to just run your eye over my post to see if there are any obvious errors?

From the number of posts there are a lot of people that have problems installing 3rd party plugins.

Regards
Jimmy

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

How to install the cordova-plugin-background-mode plugin

Hi Jimmy -

You can use Weinre debugger when running your app on the device to determine, if there are some errors or place braking points to see if the code actually is running on the device.
:: https://devcenter.appery.io/documenta...
:: https://devcenter.appery.io/documenta...

Widad
Posts: 0
Joined: Thu Sep 03, 2015 11:09 am

How to install the cordova-plugin-background-mode plugin

Hello JimmyH I have the same problem with this plugin how do you solve this problem ???

Return to “Issues”