PhoneGap 3.1构建设备未定义

我有一个sencha触摸项目。 我用phonegap 2.9构建并且工作正常device.uuid返回设备ID。 当我尝试使用3.1 device.uuid构建“设备未定义”错误时。 我的config.xml

         

我的设备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:

  

您还可以删除以下行,因为APIfunction现在由新的插件格式处理。

无用的线条:

     

将您的注册码放在DeviceReadyfunction下

 var platform = null; document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { platform = device.platform; //alert(platform); $("#app-status-ul").append('
  • '+ platform +'
  • '); try { pushNotification = window.plugins.pushNotification; $("#app-status-ul").append('
  • registering ' + device.platform + '
  • '); 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); } }