5

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?

1

2 Answers 2

10

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

4

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.