Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can phonegap app work in background?

what I mean is working in totally background, e.g. even the screen is shut down, the app is running and can send notifications with a sound.

My app is used for watching price changes. There will be an alert with a sound when a price changes.

So, the answer should be yes or no? Thanks.

like image 232
Leo Cai Avatar asked Jan 08 '13 08:01

Leo Cai


People also ask

Which one is the PhoneGap limitation?

Plugins could be outdated. The next limitation is that the plugins of the PhoneGap can be outdated after using it. It can affect application functionality. We don't have plugins for certain features like geolocation, camera, etc.

Is PhoneGap still alive?

Yes, you read it right! PhoneGap and PhoneGap Build are shutting their doors by October 1, 2020. With that, Adobe is shuttering its investment in the Apache Cordova.

What happened to PhoneGap?

Adobe is discontinuing PhoneGap, PhoneGap Build, and Apache Cordova on October 1st, 2020.


2 Answers

Here is some links which can help you in this

link 1 : Similar SO question

link 2 : Red-Folder Blog

link 3 : BackgroundService Plugin in GitHub

Update

link 4 : Phonegap background service on iOS4

link 5 : phonegap background service in iOS5

like image 50
Melvin Joseph Mani Avatar answered Sep 20 '22 01:09

Melvin Joseph Mani


Since there came another possible solution with iOS 7, I'm gonna provide an additional answer for users of iOS 7 and further.

The new Background Fetch feature, makes it possible to regularly update content for an app which is in the background. The time interval of the fetching cannot be set by the user, but is rather set by the iOS based on its user's statistics (app usage, etc.).

This new feature can be accessed with PhoneGap/Cordova via plugins - fortunately there has already been developed a plugin providing this access. You can install it to your Cordova project by

cordova plugin add https://github.com/christocracy/cordova-plugin-background-fetch.git 

In conjunction with a plugin providing access to iOS's local notifications, this works wonders. Such a plugin has also been developed, for example this one. Install it to your Cordova project by

cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git 

These plugins can now be combined in your javascript code, to execute background activities:

function onDeviceReady() {     var Fetcher = window.plugins.backgroundFetch;      // Your background-fetch handler.     var fetchCallback = function() {         console.log('BackgroundFetch initiated');          // perform your ajax request to server here         $.get({             url: '/heartbeat.json',             callback: function(response) {                 // process your response and whatnot.                  window.plugin.notification.local.add({ message: 'Just fetched!' });  //local notification                 Fetcher.finish();   // <-- N.B. You MUST called #finish so that native-side can signal completion of the background-thread to the os.             }         });     }     Fetcher.configure(fetchCallback); } 

This fetching plugin is using the UIApplicationBackgroundFetchIntervalMinimum value for the fetching interval, this results in the fastest possible fetching periodicity.

like image 33
Clawish Avatar answered Sep 19 '22 01:09

Clawish