This is a migrated thread and some comments may be shown as answers.

How to prevent application to exit

29 Answers 331 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Keen
Top achievements
Rank 1
Keen asked on 13 Jun 2013, 08:43 AM
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

29 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 13 Jun 2013, 09:31 AM
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.
0
Keen
Top achievements
Rank 1
answered on 13 Jun 2013, 09:51 AM
Hi steve,
     I see, because I have a one time log-in part on my apps..
0
Steve
Telerik team
answered on 13 Jun 2013, 11:06 AM
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.
0
Keen
Top achievements
Rank 1
answered on 14 Jun 2013, 01:11 AM
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.
0
Steve
Telerik team
answered on 14 Jun 2013, 07:52 AM
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.
0
Keen
Top achievements
Rank 1
answered on 25 Jun 2013, 07:58 AM
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
0
Stefan Dobrev
Telerik team
answered on 25 Jun 2013, 10:08 AM
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.
0
Keen
Top achievements
Rank 1
answered on 26 Jun 2013, 12:35 AM
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
0
Iva Koevska
Telerik team
answered on 01 Jul 2013, 11:10 AM
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.
0
Keen Mark
Top achievements
Rank 1
answered on 02 Jul 2013, 07:29 AM
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
0
Keen
Top achievements
Rank 1
answered on 02 Jul 2013, 09:39 AM
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.
0
Iva Koevska
Telerik team
answered on 02 Jul 2013, 10:53 AM
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.
0
Keen
Top achievements
Rank 1
answered on 02 Jul 2013, 11:13 AM
Hi iva,

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

thanks
0
Keen
Top achievements
Rank 1
answered on 02 Jul 2013, 11:26 AM
Hi iva,

Its not working..theres no alert message..

0
Iva Koevska
Telerik team
answered on 02 Jul 2013, 11:36 AM
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.
0
Keen
Top achievements
Rank 1
answered on 02 Jul 2013, 11:41 AM
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
0
Iva Koevska
Telerik team
answered on 02 Jul 2013, 12:05 PM
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.
0
Keen
Top achievements
Rank 1
answered on 02 Jul 2013, 12:09 PM
Hi Iva,
ok I will now deploy it on my device to test and compare it on my sample. Thanks.


Keen
0
Keen
Top achievements
Rank 1
answered on 02 Jul 2013, 02:06 PM
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
0
Iva Koevska
Telerik team
answered on 02 Jul 2013, 03:44 PM
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.
0
Keen
Top achievements
Rank 1
answered on 03 Jul 2013, 04:52 AM
Hi Iva,

Approximately 3hours the apps exit again

Thanks
Keen
0
Keen
Top achievements
Rank 1
answered on 08 Jul 2013, 01:08 AM
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
0
Keen
Top achievements
Rank 1
answered on 11 Jul 2013, 09:09 AM
Hi Telerik team,

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

Thanks,
Keen
0
Steve
Telerik team
answered on 11 Jul 2013, 03:04 PM
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.
0
Jay
Top achievements
Rank 1
answered on 08 Sep 2013, 02:21 AM
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.
0
Steve
Telerik team
answered on 10 Sep 2013, 03:41 PM
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.
0
Richard
Top achievements
Rank 1
answered on 28 Dec 2013, 12:52 AM
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
0
Nikola
Telerik team
answered on 30 Dec 2013, 10:04 AM
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.
0
Richard
Top achievements
Rank 1
answered on 30 Dec 2013, 08:10 PM
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
Tags
General Discussion
Asked by
Keen
Top achievements
Rank 1
Answers by
Steve
Telerik team
Keen
Top achievements
Rank 1
Stefan Dobrev
Telerik team
Iva Koevska
Telerik team
Keen Mark
Top achievements
Rank 1
Jay
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Nikola
Telerik team
Share this question
or