簡體   English   中英

無法獲得phonegap device.platform工作

[英]can't get phonegap device.platform to work

我正在使用Xcode並嘗試獲取設備的信息,但它沒有顯示出來。 這是我的代碼

<!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>

警報(1)彈出,但它只是跳過警報(2)和警報(狀態)。 我正在使用PhoneGap 3.0,我做錯了什么?

安裝步驟在http://docs.phonegap.com/en/3.1.0/cordova_device_device.md.html#Device,你需要安裝插件(cordova 3+)

    cordova plugin add org.apache.cordova.device

IOS不應該在config.xml中需要任何特殊配置

檢查你的xcode項目中config.xml(/config.xml)中的插件標簽。 查看是否添加了“設備”插件。

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM