javascriptcordovacordova-2.0.0

navigator.app.exitApp(); results in "TypeError: Cannot call method 'exitApp' of undefined"


Cordova 2.0.0

The following API call doesn't work on Chrome browser, as expected;

navigator.app.exitApp();

I'm getting

TypeError: Cannot call method 'exitApp' of undefined

My code is simply including the cordova-2.2.0.js file. No further actions taken regarding PhoneGap.

On the mobile device this API call does work.

So I'm guessing there's an additional step I should take in order to abstract this sort of API functions??? Maybe some sort of "require" call?

Edit #1:
I think it wasn't clear enough: I was hoping that Cordova would abstract this sort of API so that even if not really available (i.e not under a real device but under Chrome instead), these calls would do nothing (especially exitApp).

In addition - I can see navigator object in Chrome inspection, which is of type CordovaNavigator.


Solution

  • Well, you're trying to use cordova native calls on chrome, wich of course won't run, cordova native calls are made to access native mobile features, wich Chrome doesnt emulate.

    Also i recommend you to use always the lastest stable version, cordova is already on version 2.8

    You can get the chrome addon ripple emulator to test cordova apps on it, still it doenst support some cordova features : http://emulate.phonegap.com