navigator.app.exitApp issues

4 posts, 0 answers
  1. AlexFStop
    AlexFStop avatar
    7 posts
    Member since:
    Jan 2014

    Posted 15 May 2014 Link to this post

    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.
  2. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 19 May 2014 Link to this post

    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!

     
  3. Isaac
    Isaac avatar
    3 posts
    Member since:
    Oct 2014

    Posted 21 Oct 2014 in reply to Kaloyan Link to this post

    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
  4. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 24 Oct 2014 Link to this post

    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.

     
Back to Top