[英]Ionic 4 native Device plugin returns device uuid null on platform browser
By running ionic cordova run browser
device uuid is null as Device object is empty on browser platform.通过运行ionic cordova run browser
device uuid is null 因为 Device 对象在浏览器平台上是空的。
Device info should be there as it supports browser platform like设备信息应该在那里,因为它支持浏览器平台,如
platform: browser
uuid: "someid"
platform: browser
uuid: "someid"
Here's my code:这是我的代码:
import { Device } from '@ionic-native/device/ngx';
constructor(private device: Device) { }
console.log('Device UUID is: ' + this.device.uuid);
Result: Device UUID is: null
结果: Device UUID is: null
I'm using @ionic-native/device": "^5.5.0
我正在使用@ionic-native/device": "^5.5.0
Please help me out how to resolve this problem.请帮我解决这个问题。 I have tested the code on android device.我已经在安卓设备上测试了代码。 It's working fine它工作正常
Sadly the device.uuid
property is not supported on the browser platform.遗憾的是浏览器平台不支持device.uuid
属性。 See the supported platforms here .请在此处查看支持的平台。
So you might want to check the device.platform
beforhand and handle the browser platform differently something like this:所以你可能想事先检查device.platform
并以不同的方式处理浏览器平台,如下所示:
if (this.device.platform === 'browser') {
console.log('Device UUID is not supported on browser platform');
} else {
console.log('Device UUID is: ' + this.device.uuid);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.