Android上的PhoneGap中的device.uuid未定义? [英] device.uuid undefined in PhoneGap on Android?

查看:130
本文介绍了Android上的PhoneGap中的device.uuid未定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个PhoneGap应用程序,向中央数据库发送请求。它需要能够识别连接到它的唯一设备。

I'm writing a PhoneGap application that sends requests to a central database. It needs to be able to identify the unique devices that connect to it.

PhoneGap的 device.uuid 属性似乎可以做到这一点。在webOS和iPhone上,我得到一个独特的字母数字字符串,这将满足我的需要。但是,我测试的Android设备(Motorola Droid和Android SDK模拟器,都运行Android 2.1)返回undefined为 device.uuid

PhoneGap's device.uuid property would seem to do the trick. On webOS and iPhone, I get back a unique string of alphanumeric characters, which will satisfy my need. However, the Android devices I've tested (Motorola Droid and the Android SDK emulator, both running Android 2.1) return "undefined" as the device.uuid.

device.platform device.name 在所有三个平台,所以问题不是与设备对象本身(它是在我使用它的代码块中定义的)。

device.platform and device.name return correct values on all three platforms, so the problem doesn't have to do with the device object itself (it's defined in the code blocks where I use it).

这是Android的限制吗? PhoneGap有问题吗?

Is this an Android limitation? A problem with PhoneGap?

如果没有通过 device.uuid

编辑:看起来 deviceready 事件从未被触发,

It appears that the deviceready event is never getting fired, which needs to happen before the device.uuid property becomes available.

推荐答案

根据PhoneGap版本和/或设备,您可能需要显式安装插件。在我们的项目中,设备存在,但device.uuid未定义。运行 cordova插件添加org.apache.cordova.device 修复了我们的问题。

Depending on Phonegap version and/or device, you might need to install the plugin explicitly. In our project, device was present but device.uuid was undefined. Running cordova plugin add org.apache.cordova.device fixed the issue in our case.

这篇关于Android上的PhoneGap中的device.uuid未定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆