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?
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?
Share Improve this question asked Aug 26, 2013 at 1:10 子維 宋子維 宋 851 silver badge11 bronze badges 1- 1 do you add device plugin – Amit Prajapati Commented Aug 26, 2013 at 1:54
2 Answers
Reset to default 10steps for installation are at http://docs.phonegap./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>