Detect if you are working inside PhoneGap / Cordova

There were a few questions about how to detect an HTML page running inside the device as a phone call application.

Most of the solutions ( here and here ) were

  • Detect if browser agent is iPhone / iPad / Android / Blackberry.
  • Use the "deviceready" event to detect operation inside the device.
  • Use URL to determine if the protocol is HTTP or FILE

Are there any other solutions? All 3 will not work for me, since I run HTML development files locally before compiling the application, as a result it will detect 1). and 2). will shoot and 3). really is a FILE protocol.

+4
source share
2 answers

In the local file and mobile web site, deviceready will not start because this is a special PhoneGap event. therefore, you can set the IsRunningOnPhoneGap flag in the device ready event.

+2
source

It works:

if (window.cordova) { document.addEventListener("deviceready", onReady, false); } else { onReady(); } 
0
source

All Articles