Background service in apache cordova application

I need to poll the server at a given interval using the Apache Cordova application and notify the user if there is relevant information for him. I'm not sure that this can be done with webmasters, because an event (server polling) should also happen when the application is inactive in iOS and Android.

Has anyone encountered a similar problem ?, I looked at local notifications / dialogs for message delivery, but I'm not sure how to create a polling service.

Thanks in advance.

+6
source share
1 answer

In my eyes, a continuous survey is never a good solution. I would advise you to use Push, so your server notifies the application as soon as new content arrives. This saves a lot of battery on your device because it only woke up if there really is an update. Push Notification Services is built specifically for this purpose.

Look at the excellent Push Plugin for Phonegap , which works for iOS, Android and even more platforms. To set up Push Plugin for iOS and Android, you can read the Holly Shinsky tutorial here .

In the Ray Wenderlich tutorial, here you will find information on how you could describe the back end in detail.

If you really want to stick to the survey, I know there is an opportunity to do it on iOS (see this article about Background Fetch ), not sure about Android (I think you will need to implement the Service). However, I never found a Phonegap plugin that handles background execution for both platforms accordingly.

+6
source

Source: https://habr.com/ru/post/975240/


All Articles