How to prevent application to exit

30 posts, 0 answers
  1. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 13 Jun 2013 Link to this post

    Hi guys
        Is there a way on how an apps on ios device will not exit? as I examine ,if we do not use the apps even its open, after a few minutes it will exit. Is there a way to prevent that? thanks
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 13 Jun 2013 Link to this post

    Hi Keen,

    There is no way to prevent the app from being suspended. Per Apple's documentation, unless your app has registered for one of the specific background processes:
    • Playing music
    • GPS tracking
    • VoIP

    it would be suspended after some period of time (usually around 10 mins)

    Regards,

    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  3. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 13 Jun 2013 Link to this post

    Hi steve,
         I see, because I have a one time log-in part on my apps..
  4. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 13 Jun 2013 Link to this post

    Hello Keen,

    A possible solution would be to enable the idle timer for the application, which could be accomplished by setting the idleTimerDisabled property to YES. This is not directly exposed in Cordova, but can be controlled via a custom Cordova plug-in (PowerManagement). Custom plug-ins (plugman compatible) support would be introduced in the upcoming version 1.6.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  5. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 13 Jun 2013 Link to this post

    Hello Steve,

    Is version 1.6 will arrive soon so we can use the function that will not exit the apps? Because my Boss said,that function is really important to us,we cant buy Icenium yet because we are working on the process if Icenium can give the functions that we needed in the one we are developing for our clients.

    We are really appreciate help and consideration as for future consumer of Icenium. Icenium is really good! we don't have doubt about that.
  6. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 14 Jun 2013 Link to this post

    Hi Keen,

    Thanks for the kind words about the product once again. Version 1.6 would be available at the end of the month.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  7. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 25 Jun 2013 Link to this post

    Hi Steve,

       Looks like Icenium had an updgrade. is that the version 1.6? if its 1.6 . Can you tell me now how to avoid program to exit? hehe as we discuss in this thread.

    anyways. Graphite doesn't work when I upgrade it. :)it was stuck just like in the picture provided .

    Thanks

    Keen
  8. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 25 Jun 2013 Link to this post

    Hi Keen,

    We have just updated Icenium and everything should work after you update Graphite. Here are the release notes for this release.

    Regards,
    Stefan Dobrev
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  9. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 25 Jun 2013 Link to this post

    Hi stefan

       Thanks for the response. Can you direct me to the part of how to prevent the application to exit ? I cant see the idle function your talking about.

    thank you
    Keen
  10. Iva Koevska
    Admin
    Iva Koevska avatar
    286 posts

    Posted 01 Jul 2013 Link to this post

    Hi Keen,

    Unfortunately, the plugin that Steve has recommended in an earlier reply, does not meet the requirements of Icenium for custom Apache Cordova plugins at this moment. As you have already noticed and reported in another thread, you will need to perform a few additional steps to make the plugin work with your project.

    Here is the entire process if you are using Graphite.

    1. Download the plugin files. 
    2. Create the directory structure required by Plugman. You can learn more about it here.
      2.1. In the plugin root, create two folders: src and www.
      2.2. In src, create a folder named ios. Move *.h and *.m files to ios.
      2.3. In www, move *.js files.
      2.4. In the root, create an empty plugin.xml file. 
    3. Zip the contents of the plugin folder.
    4. In Graphite, open your project and import the plugin. To import the plugin, in the Project Navigator, right-click the Plugins folder and click Import Plugin. Because plugin.xml is currently empty, you might notice a few exceptions in the log - do not worry about them at this point.
    5. Edit plugin.xml according to the Plugman specification. To make editing easier, use this code as a reference. In the sample code, make all the necessary changes to filepaths, titles, identifiers, etc.
    6. In index.html, add a reference to the plugin .js file.
    7. In your code, make the necessary changes to make use of the plugin. (For testing purposes, you can check out the code suggestions in this StackOverflow thread.)
    8. Save all changes and run your app on device. Note that you will not be able to run this in the simulator as the simulator does not support plugins.

    For your convenience, we have added the reworked plugin sample as a .zip file. You will notice the modified structure and the added plugin.xml.  You can import it into your project and review the changes. Hope that helps.

    For more information about working with custom plugins, see this section in the documentation.
     
    Regards,
    Iva Koevska
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  11. Keen Mark
    Keen Mark avatar
    7 posts
    Member since:
    May 2013

    Posted 02 Jul 2013 Link to this post

    Hi Iva

    Thanks for the plugin. but im targeting now IOS device. Do i need to write "application.IdleTimedDisabled= YES"? and if its included. where do i put that code.thanks
  12. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 02 Jul 2013 Link to this post

    Hi Iva,

    I already put the plugins in my sample apps just to try if its working. But Its not working. Im sure I followed everything and try the plugins that you gave to me.
    Is there any declaration that I need to put to active the plugin? like in xcode they use idletimerdisabled= YES?.

    Thanks for the plugin and response.
  13. Iva Koevska
    Admin
    Iva Koevska avatar
    286 posts

    Posted 02 Jul 2013 Link to this post

    Hello Keen,

    As stated in step 7, you need to implement the plugin in your code. You do need to call  the acquire method to prevent your iOS device from exiting your app. You can use the StackOverflow thread I suggested earlier to get some ideas how to put the plugin to use. Here's a quick breakdown how to apply the sample from StackOverflow.

    1. Make sure that index.html contains a reference to the plugin script file.
    2. In the script file that contains your app functionality (for example: index.js, main.js), insert the following code.
      function acquire() {
                  cordova.require('cordova/plugin/powermanagement').acquire(
                          function() { alert( 'successfully acquired full wake lock' ); },
                          function() { alert( 'error acquiring full wake lock' ); }
                          );
              };
    3. In index.html, within the <body> block, insert the following code.
      <button type="button" onclick="acquire();">acquire</button>
      <br />

    This will create an app with an acquire button. After you press it, the app will remain active and will not exit automatically. In the Stackoverflow thread you can also see how to release the app and use the rest of the plugin features.

    Hope that helps you get a few ideas how to put the plugin to use in your own app.

    Regards,
    Iva Koevska
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  14. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 02 Jul 2013 Link to this post

    Hi iva,

    Im using a jquerymobile . I will try right now please stay on ..

    thanks
  15. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 02 Jul 2013 Link to this post

    Hi iva,

    Its not working..theres no alert message..

  16. Iva Koevska
    Admin
    Iva Koevska avatar
    286 posts

    Posted 02 Jul 2013 Link to this post

    Hi Keen,

    Have you deployed this on a physical iOS device? Keep in mind, that you cannot test this in Ion or in the simulator. 

    Regards,
    Iva Koevska
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  17. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 02 Jul 2013 Link to this post

    Hi Iva,

    Yes Currently its on device. I put the added button on my index.html and function to be called when its successfully acquire the plugin. but theres no alert message. im using jquery mobile and targeting ios device..

    Thanks
  18. Iva Koevska
    Admin
    Iva Koevska avatar
    286 posts

    Posted 02 Jul 2013 Link to this post

    Hi Keen,

    Just in case, I have prepared a very basic sample, based on the jQuery Mobile template and the code and plugin modifications I have already posted. You can find it attached. You can use the attached archive to recreate the project in your own environment as per the procedure described in the documentation. You can start straight from Step 2 (select a jQuery template as a starter), as you already have the exported project.

    Set a proper application identifier and select a cryptographic identity for the app, build it, deploy it on device, launch it and tap the Acquire button. The alert should appear and your app should stay awake until you exit it manually. Just as a reminder - do not run this in Ion, as it will not work.

    Hope that helps.

    Regards,
    Iva Koevska
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  19. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 02 Jul 2013 Link to this post

    Hi Iva,
    ok I will now deploy it on my device to test and compare it on my sample. Thanks.


    Keen
  20. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 02 Jul 2013 Link to this post

    Hi again Iva,

    The sample apps you gave is but auto exit and refreshing after 1 hours , I also applied that on my sample but exit/refresh on after 1 hour. What I want is to not exit the apps unless it was turn off.

    Keen
  21. Iva Koevska
    Admin
    Iva Koevska avatar
    286 posts

    Posted 02 Jul 2013 Link to this post

    Hi Keen,

    It appears that there are a few known issues with the behavior of  idleTimerDisabled that cause applications to exit after a while or after using a service such as the camera. This is an unstable and unpredictable behavior and the known workarounds do not always work. You can read more about it here, here, here, and here.

    I have reworked some of the plugin code and I have tested it on an iPad Mini. More than an hour has passed and the app still hasn't exited. You can find the modified file attached (as a zip file). Unzip it and use it to replace the existing Plugins\PowerManagement\src\ios\PowerManagement.m file in the project.

    Let me know if that helped.

    Regards,
    Iva Koevska
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  22. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 02 Jul 2013 Link to this post

    Hi Iva,

    Approximately 3hours the apps exit again

    Thanks
    Keen
  23. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 07 Jul 2013 Link to this post

    Hi,
    Im willing to wait that plugin will be ok. we really need that before we buy the Icenium.
    We want the apps not to exit.
    I know the telerik team can help us with this.


    Thanks
    Keen
  24. Keen
    Keen avatar
    101 posts
    Member since:
    Mar 2013

    Posted 11 Jul 2013 Link to this post

    Hi Telerik team,

    Is there any solution for this? We need badly..

    Thanks,
    Keen
  25. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 11 Jul 2013 Link to this post

    Hello Keen,

    Our product support for custom Cordova plug-ins include adding the plug-in as part of your project and the project successfully built on our cloud server. Bugs/missing features or unexpected behavior of a Cordova plug-in is problem of the plug-in itself and does not fall in our domain (respectively support).

    Our suggestion to you is to try contacting the plugin authors for advice or opening an issue on the plug-in's Github issues page directly. Or you can also try to help yourself by using the suggestions how to modify the plug-in from the forum threads that we have suggested previously.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  26. Jay
    Jay avatar
    4 posts
    Member since:
    Mar 2013

    Posted 07 Sep 2013 Link to this post

    Any idea what I might be missing when trying to run this on android? I took your build and altered the plugin.xml to have an android section like this:
    <!-- android -->
        <platform name="android">

        <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <activity android:name="org.apache.cordova.plugin.PowerManagement"
                android:label="@string/app_name">
                <intent-filter>
                </intent-filter>
            </activity>
        </config-file>

        <config-file target="res/xml/config.xml" parent="plugins">
            <plugin name="PowerManagement"
                value="org.apache.cordova.plugin"/>
        </config-file>

        <source-file src="src/android/org/apache/cordova/plugin/PowerManagement.java" 
                target-dir="src/org/apache/cordova/plugin"/> 

        </platform>

    then I added the <uses-permission android:name="android.permission.WAKE_LOCK" /> line to the android manifest.
    then I copied the whole project folders and files to Plugins / PowerManagement / src / android /

    but then i get the "error acquiring full wake lock" message.
    Any ideas or could a plugin sample be updated with the android code support in it too?
    attached is my plugins.zip inside a jpg file. just open it with a zip file.
  27. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 10 Sep 2013 Link to this post

    Hello Jason,

    You should change the id of the custom plugin to match the value for the plugin that is added to config.xml i.e. here is the modified plugin.xml:

    <?xml version="1.0" encoding="UTF-8"?>
        id="org.apache.cordova.plugin.powermanagement"
        version="1.0">
     
        <name>PowerManagement</name>
     
        <asset src="www/powermanagement.js" target="powermanagement.js" />
         
        <!-- ios -->
        <platform name="ios">
            <!-- Cordova < 2.3 -->
            <plugins-plist key="PowerManagement" string="PowerManagement" />
     
            <!-- Cordova >= 2.3 -->
            <config-file target="config.xml" parent="plugins">
                <plugin name="PowerManagement" value="PowerManagement"/>
            </config-file>
     
            <header-file src="src/ios/PowerManagement.h" />
            <source-file src="src/ios/PowerManagement.m" />
             
        </platform>
    <!-- android -->
        <platform name="android">
     
        <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <activity android:name="org.apache.cordova.plugin.PowerManagement"
                android:label="@string/app_name">
                <intent-filter>
                </intent-filter>
            </activity>
        </config-file>
     
        <config-file target="res/xml/config.xml" parent="plugins">
            <plugin name="PowerManagement"
                value="org.apache.cordova.plugin.PowerManagement"/>
        </config-file>
     
        <source-file src="src/android/org/apache/cordova/plugin/PowerManagement.java"
                target-dir="src/org/apache/cordova/plugin"/>
        </platform>
    </plugin>


    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  28. Richard
    Richard avatar
    24 posts
    Member since:
    May 2012

    Posted 27 Dec 2013 Link to this post

    Steve,
    I also need this badly. I downloaded the latest version which works with Cordova 3.x at  https://github.com/Viras-/cordova-plugin-powermanagement. I created a Kendo UI application in Icenium with Cordova 3.2.  I believe have made the custom plugin call work because I could see the message "successfully acquired full wake lock". But after switching to another application for 15 minutes then switching back, the application had existed. I could see it was reloading and the login session was gone. The user would have to login again.

    When iOS 6, the login session lasted lot longer. Now it becomes a big problem. I don't know if there is fix to it. 

    Thanks!

    Richard
  29. Nikola
    Admin
    Nikola avatar
    22 posts

    Posted 30 Dec 2013 Link to this post

    Hello Richard,

    The scenario you describe is impossible to implement on iOS. The application has no way of controlling what happens to it, once the user has switched to another application. Therefore, if the operating system detects that the device is running low on memory, it will terminate your application. The PowerManagement plugin is designed to prevent the device from going to sleep while the application is running, not to prevent the system from terminating it. You can review Apple's documentation on App States and Multitasking (what you need) and on IdleTimeDisabled (what the plugin does).

    Depending on what you want to do while the app is in the background, you may want to utilize some of the background modes, supported by iOS. For more information on supported background modes, you can refer to the Background Execution and Multitasking section of Apple's documentation.

    If you need further assistance, I'll be happy to help you out.

    Regards,
    Nikola
    Telerik
    You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  30. Richard
    Richard avatar
    24 posts
    Member since:
    May 2012

    Posted 30 Dec 2013 Link to this post

    Nikola,
    Thanks for making it clear. Making the app running at the background is just a workaround to my problem. The right fix is to persist session/cookie information.I was on the right track but was turned away by the behavior in simulator. The following call in Icenium simulator always returns back null: 


    xhr.getResponseHeader('Set-Cookie')


    But it actually works on the physical devices. So I save the cookies in the local storage. When application got restarted, I'll read them from the local storage and set the cookies when making ajax calls. The logic is kind of complex but it works!

    So I found my solution and the users won't need login every ten minutes. I'll come back to this thread when I really need the applications running at the background. For now, I'm happily waiting for the new year.

    Thanks for your help and happy new year to you!

    Richard
Back to Top