I'm using Xcode and trying to get the device's info, but it's not showing up. Here is my code
<!DOCTYPE html>
<html>
<head>
<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, true);
// device APIs are available
function onDeviceReady() {
alert('1');
var status = device.platform;
alert('2');
alert(status);
$("#deviceProperties").html(status) ;}
</script>
</head>
<body>
<p id="deviceProperties">Loading device properties...</p>
</body>
</html>
alert (1) pop up, but it just skip alert (2) and alert(status). I'm using PhoneGap 3.0,what am I doing wrong?
Apache Cordova and Adobe PhoneGap provide a way for developers to develop apps for all major platforms in HTML, CSS and JavaScript. Developers only have to maintain a single codebase for all platforms. The project started out as PhoneGap and when it was acquired by Adobe the code was released as Apache Cordova.
steps for installation are at http://docs.phonegap.com/en/3.1.0/cordova_device_device.md.html#Device you need to install plugin (cordova 3+)
cordova plugin add org.apache.cordova.device
IOS shouldnt require any special configuration in config.xml
check your plugin tag in your config.xml (/config.xml) in you your xcode project. See if 'Device' plug-in is added.
<widget>
...
<plugins>
<plugin name="Device" value="CDVDevice" />
<plugin name="Logger" value="CDVLogger" />
<plugin name="Compass" value="CDVLocation" />
<plugin name="Accelerometer" value="CDVAccelerometer" />
<plugin name="Camera" value="CDVCamera" />
<plugin name="NetworkStatus" value="CDVConnection" />
<plugin name="Contacts" value="CDVContacts" />
<plugin name="Debug Console" value="CDVDebugConsole" />
<plugin name="Echo" value="CDVEcho" />
<plugin name="File" value="CDVFile" />
...
</plugins>
</widget>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With