Keep application running while screen is turned off

Thread is closed for posting
5 posts, 0 answers
  1. perico
    perico avatar
    28 posts
    Member since:
    Dec 2006

    Posted 27 Jan 2017 Link to this post

    Hi,

    I want to use a countdown in my application but when the screen turns off, it pauses after ~20 sec and resumes when the screen turns on.

    Is there a way to fix it ?

    Thank you.

  2. perico
    perico avatar
    28 posts
    Member since:
    Dec 2006

    Posted 30 Jan 2017 Link to this post

    This plugin works properly

    https://github.com/Telerik-Verified-Plugins/Insomnia

    But it's not the best option.

  3. Preslav
    Admin
    Preslav avatar
    452 posts

    Posted 01 Feb 2017 Link to this post

    Hi Perico,

    Based on your post, I believe that the Cordova Background mode plugin might provide the required functionality. This plugin prevents the app from going to sleep while in the background.

    Additionally, to import this plugin in an app, you will need to download it as a ZIP file from GitHub and then follow the procedure outlined here.

    Regards,
    Preslav
    Telerik by Progress
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  4. perico
    perico avatar
    28 posts
    Member since:
    Dec 2006

    Posted 02 Feb 2017 in reply to Preslav Link to this post

    Hi Preslav,

    Thank you for your post.

    I've already seen this plugin but it seems that there is a problem to publish app's on the appStore  

    https://github.com/katzer/cordova-plugin-background-mode/issues/122

  5. Preslav
    Admin
    Preslav avatar
    452 posts

    Posted 06 Feb 2017 Link to this post

    Hi Perico,

    You are correct. Indeed the app might get rejected from the App Store. 

    Unfortunately, I was not able to find any other solution that can provide such functionality out of the box.

    A possible solution in this situation might be using the pause and resume Cordova events. For example, on pause, you could save the timer in a variable. Once the resume event fires, you could calculate the time and update the countdown timer.

    Additionally, you might be interested in the iOS Background Execution article.

    Regards,
    Preslav
    Telerik by Progress
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top