[Phonegap Build] Will it be possible to use config.xml to specify app running in background?

  • 11
  • Question
  • Updated 7 years ago
  • Answered
Will it ever be possible to use config.xml to specify that the app must continue when it is in the background? At this moment my app doesn't continue on iOS in the background.

When I view my app on an iOS device through the native browser and I start an other app it is still running in the background, but with Phonegap Build it isn't:(.
Photo of S1f1

S1f1

  • 2 Posts
  • 0 Reply Likes
  • sad

Posted 8 years ago

  • 11
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Hey S1f1,

We have not exposed this via our config.xml yet, I've added it to our backlog of tasks to look at/implement.

Hardeep Shoker
Photo of Muhammad Umer

Muhammad Umer

  • 8 Posts
  • 0 Reply Likes
where is that at\implement
Photo of Muhammad Umer

Muhammad Umer

  • 8 Posts
  • 0 Reply Likes
is it implemented yet
Photo of S1f1

S1f1

  • 2 Posts
  • 0 Reply Likes
Hi Hardeep,

Thank you for adding it to your backlog, it would be great if this will be supported in the future. At the moment I'm building an application with phonegap build for a company that would create many more phonegap apps if this feature will be supported. Thanks!

S1f1
Photo of taxi requester

taxi requester

  • 1 Post
  • 0 Reply Likes
Hello,

Is there any news about an app running in background?
We are also developing in phonegap and it is very important.
Photo of Joe Meeks

Joe Meeks

  • 40 Posts
  • 3 Reply Likes
Also very interested in this feature.
Photo of Dany Marmur

Dany Marmur

  • 1 Post
  • 1 Reply Like
Enormously important to me too :)
Photo of maurizio

maurizio

  • 60 Posts
  • 1 Reply Like
I also have this problem ..
Photo of Tommaso Cardone

Tommaso Cardone

  • 36 Posts
  • 0 Reply Likes
any news?
Photo of Evandro

Evandro

  • 0 Posts
  • 0 Reply Likes
Any news about this? It's a very important feature that miss in PhoneGap.
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
Use exit-on-suspend for iOS, keepRunning for Android.

iOS: https://build.phonegap.com/docs/confi... (see exit-on-suspend preference)
Android: http://docs.phonegap.com/en/3.0.0/gui...
Photo of Eric McGuire

Eric McGuire

  • 3 Posts
  • 0 Reply Likes
Can you elaborate a little bit on how this would be implemented using the links you just provided above?
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
Add the following tags to your config.xml file:


<preference name="exit-on-suspend" value="true" />
<preference name="keepRunning" value="false" />


These preference settings should cause your app to stop running when the user 'hides' it on iOS and Android, respectively.
Photo of Tommaso Cardone

Tommaso Cardone

  • 36 Posts
  • 0 Reply Likes
Hello.
I've tried the keepRunning preference (true) but don't work for me...
Any suggestion?
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
I just tested this as well and discovered that the Cordova docs are not clear on this behaviour. Setting KeepRunning=false will not actually cause your app to be killed upon being put in the background -- it will simply halt any execution of code in the webview while the app is in the background.

i.e:
setInterval(function() {
console.log('running!');
}, 3000);


If keepRunning=false then that code will not execute while the app is in the background.

I've send a request to clarify those docs.
Photo of Tommaso Cardone

Tommaso Cardone

  • 36 Posts
  • 0 Reply Likes
Thank you Ryan. So... there is a way to mantain running the app in background and prevent the os to kill the app?
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
Tommaso are you finding that the OS is killing your app when hidden? By default the app should continue to run in the background.

Can you share your App ID? Also what platform (iOS, Android version) are you testing on?
Photo of Tommaso Cardone

Tommaso Cardone

  • 36 Posts
  • 0 Reply Likes
My app is killed by Android after some time that is in background. My app ID is 387141
My android version is 4.1.2
Photo of Maurizio Sordo

Maurizio Sordo

  • 15 Posts
  • 1 Reply Like
Hi Tommaso

Android kill the backgrounds app when S.O. need more resources.
With PGB you haven't solutions.
You must write a Android Service that check if the App is running, otherwise restart it.
You must use this plugin
https://github.com/Red-Folder/Cordova...
But you must use Eclipse and ADK .

For iOS you can't use PGB if you want running app in background,
because you must change in plist this key "UIBackgroundModes" and PGB not permit it, you must use xCode

For iOS you can't use PGB if you want running app in background,
because you must change config.xml (only for webworks) adding this parameter:
run_when_backgrounded

My hope for the future is PGB can do all this.
Photo of Tommaso Cardone

Tommaso Cardone

  • 36 Posts
  • 0 Reply Likes
Thank you Maurizio for your reply.
i hope for the future too...