简体   繁体   English

Cordova设备插件不允许我访问“设备”属性

[英]Cordova Device plugin won't let me access the “device” properties

我安装device插件后,我的cordova应用程序使用device.uuid ,我仍然无法使用该属性,我的应用程序挂起我使用device.uuid的行。

Since iOS7 you can no longer use the device.uuid Apple made impossible to track devices. 从iOS7开始,您无法再使用device.uuid Apple无法跟踪设备。 You will have to use either the advertising id, vendor ID or create your own unique ID. 您必须使用广告ID,供应商ID或创建您自己的唯一ID。

Just to add on this, from the developers site of PhoneGap 只是在PhoneGap的开发者网站上添加这个

The uuid for iOS is not unique for a device, but is unique per application per install. iOS的uuid并非对于设备而言是唯一的,但每次安装时每个应用程序都是唯一的。 This will change if you delete the app and re-install, and possibly also when you upgrade your iOS version, or even upgrade your app per version (as we've seen in iOS 5.1). 如果您删除应用程序并重新安装,以及升级iOS版本,甚至升级您的应用程序(如我们在iOS 5.1中所见),这将会改变。 Not a reliable value. 不是一个可靠的价值。

Looks like PhoneGap/Cordova is using identifierForVendor which kan sometimes return nil and you will have to wait some time before calling it again. 看起来像PhoneGap / Cordova正在使用identifierForVendor ,kan有时会返回nil,你必须等待一段时间才能再次调用它。 Apparently this is not implemented correctly in the cordova and causes the hang in your app. 显然这在cordova中没有正确实现,导致你的应用程序挂起。

On iOS 7 apple removed the uniqueIdentifier , the device.uuid is phonegap specific and it isn't using uniqueIdentifier internally, so you can still use it. 在iOS 7的苹果移除uniqueIdentifier ,该device.uuid是特定的PhoneGap,它没有使用uniqueIdentifier内部,所以你仍然可以使用它。

To use device.uuid on phonegap 3.XX you have to add the device plugin first like this: 要在phonegap device.uuid上使用device.uuid ,您必须首先添加设备插件,如下所示:

cordova plugin add org.apache.cordova.device

It works because I've just tested it (on cordova 3.5.0). 它的工作原理是因为我刚刚测试过它(在cordova 3.5.0上)。 If you installed the plugin and it was hanging your app maybe there was some bug with your phonegap version or the plugin wasn't installed correctly. 如果您安装了该插件并且它正在挂起您的应用程序,那么您的phonegap版本可能存在一些错误,或者该插件未正确安装。

The problem with the device.uuid is that is isn't the real device uuid, from phonegap doc device.uuid的问题在于,它不是真正的设备uuid,来自phonegap doc

iOS Quirk iOS Quirk

The uuid on iOS is not unique to a device, but varies for each application, for each installation. iOS上的uuid并非设备唯一,但对于每个安装,每个应用程序都有所不同。 It changes if you delete and re-install the app, and possibly also when you upgrade iOS, or even upgrade the app per version (apparent in iOS 5.1). 如果您删除并重新安装应用程序,并且可能还在升级iOS时,甚至每个版本升级应用程序(在iOS 5.1中显而易见),它都会更改。 The uuid is not a reliable value. uuid不是一个可靠的价值。

The device.uuid isn't using identifierForVendor either, it's just a random identifier persisted on the device, but if you want to get the real identifierForVendor I've created a plugin to get it. device.uuid也没有使用identifierForVendor ,它只是设备上持久存在的随机标识符,但是如果你想获得真正的identifierForVendor我已经创建了一个插件来获取它。

https://github.com/jcesarmobile/IDFVPlugin https://github.com/jcesarmobile/IDFVPlugin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM