簡體   English   中英

PhoneGap 3.1構建設備未定義

[英]PhoneGap 3.1 Build Device Is Not Defined

我有一個sencha觸摸項目。 我用phonegap 2.9構建並且工作正常device.uuid返回設備ID。 當我嘗試使用3.1 device.uuid構建“設備未定義”錯誤時。 我的config.xml

<preference name="phonegap-version" value="3.1.0" />
<preference name="stay-in-webview" value="true" />
<access origin="*" />

<gap:plugin name="com.phonegap.plugins.barcodescanner" />
<gap:splash src="images/splash.png" />

<feature name="http://api.phonegap.com/1.0/camera" />

<feature name="Device">
  <param name="android-package" value="org.apache.cordova.device.Device" />
</feature>

我的設備ID請求:

 try
{
   Ext.getCmp('txtUUID').setValue(device.uuid);
}
catch(err)
{alert(err);

    Ext.getCmp('txtUUID').setValue('ID Okunamadı!');

}

我需要幫助。 如何解決這個問題?

我假設你正在使用phonegap構建,對嗎?

在phonegap 3中,默認情況下不再包含核心api,現在是插件,所以你必須明確添加你正在使用的任何api。

在將以下行添加到config.xml后,您應該能夠讀取UUID:

<gap:plugin name="org.apache.cordova.device" />

您還可以刪除以下行,因為API功能現在由新的插件格式處理。

無用的線條:

<feature name="http://api.phonegap.com/1.0/camera" />
<feature name="Device">
  <param name="android-package" value="org.apache.cordova.device.Device" />
</feature>

將您的注冊碼放在DeviceReady功能下

var platform = null;
        document.addEventListener("deviceready", onDeviceReady, false);
        function onDeviceReady() {
          platform = device.platform;
          //alert(platform);
          $("#app-status-ul").append('<li>'+ platform +'</li>');
          try 
            { 
                pushNotification = window.plugins.pushNotification;
          $("#app-status-ul").append('<li>registering ' + device.platform + '</li>');
                if (device.platform == 'android' || device.platform == 'Android' ||
                        device.platform == 'amazon-fireos' ) {
        pushNotification.register(successHandler, errorHandler, {"senderID":"860557673192","ecb":"onNotification"});        // required!
                } else {
                    pushNotification.register(tokenHandler, errorHandler, {"badge":"true","sound":"true","alert":"true","ecb":"onNotificationAPN"});    // required!
                }
            }
            catch(err) 
            { 
                txt="There was an error on this page.\n\n"; 
                txt+="Error description: " + err.message + "\n\n"; 
                alert(txt); 
            } 
        }

暫無
暫無

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

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