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

navigator.app.exitApp issues

3 Answers 603 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.
AlexFStop
Top achievements
Rank 1
AlexFStop asked on 15 May 2014, 05:42 AM
I am trying to exit an app by using the navigator.app.exitApp function and not succeeding at it. Here is the code: 

$(document).ready(function() {
    if (NotLoggedInToDB) {
        alert('Not logged in to DB');
        navigator.app.exitApp();
    }
...
}

I get to the alert but the app doesn't exit. As you can see, this code in right at the beginning of the document ready handler, but it doesn't work there or anywhere else in the code.
Another question is this: what is the navigator object and where does it come from? At what point does it come into existence?
What am I doing incorrectly?
Thanks in advance for your help.

3 Answers, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 19 May 2014, 02:43 PM
Hi AlexFStop,

Thank you for the sample. It looks correct. However, do you by any chance execute this on iOS? If so, I should note that it is expected not to work as Apple do not allow apps to exit programmatically. More about this can be found in this stackoverflow thread. However, please let me know if this is still not working on Android devices and I will further investigate it.

Further, the navigator object is one of the hooks between you javascript and the browser responsible for running your application. It hold all the information about the browser and it should be instantiated after the device is ready.

I hope this helps.

Regards,
Kaloyan
Telerik
 

Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

 
0
Isaac
Top achievements
Rank 1
answered on 22 Oct 2014, 03:12 AM
Hi  guys i am trying to do a function linked to a button that can close the  entire application on click.

my function is as follows but it is not working in telerik:

function exitAppPopup() {
    navigator.notification.confirm(
          'Exit ESMT ' + device.cordova + ' Demo?'
        , function(button) {
              if (button == 2) {
                  navigator.app.exitApp();
              } 
          }
        , 'Exit'
        , 'No,Yes'
    );  
    return false;
}
asePle
0
Kaloyan
Telerik team
answered on 24 Oct 2014, 02:14 PM
Hi Isaac,

Thank you for contacting.

I just checked the provided by you code and it worked on a Nexus device. Clicking the button alerted and by clicking 'Yes', the app closed.

In order to help you further, could you please share some more information about, how is this not working on your side. For example, if you try it in the AppBuilder Simulator, are there any console errors, or does the alert even show? If the issue is only reproducing when deployed on actual device, could you tell us, on what device you are trying it?

Thank you for the help in advance. I am looking forward to your reply.

Regards,
Kaloyan
Telerik
 

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

 
Tags
General Discussion
Asked by
AlexFStop
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Isaac
Top achievements
Rank 1
Share this question
or