【发布时间】:2016-07-05 22:30:09
【问题描述】:
我已尝试在此处http://ionicframework.com/docs/v2/native/device/ 关注文档,但没有得到任何回复。
home.ts
import {Component} from '@angular/core';
import {Device} from 'ionic-native';
@Component({
templateUrl: 'build/pages/home/home.html',
})
export class HomePage {
public device;
constructor() {
this.device = {};
platform.ready().then(() => {
this.device['uuid'] = Device.device.uuid;
});
}
}
home.html
<li>Device UUID is {{device.uuid}}</li>
我已经跑过ionic plugin add cordova-plugin-device
更新:我正在使用 IonicView 应用程序测试该应用程序。
【问题讨论】:
-
假设您在真实设备中执行此操作,如果将
console.log更改为console.log(Device);会发生什么? -
是的,我正在真实设备上进行测试(通过 Ionic View 应用程序)。我并不是要包含 console.log,因为它总是会在浏览器上显示警告,我不确定如何在设备上检查 console.log。
-
那是安卓设备吗?如果是这样,您可以将其插入并使用 Chrome Inspector 来了解那里发生了什么。如果你愿意,我可以写一个答案,提供有关如何做的信息。
-
是的,Android 设备。我已经研究出如何在 chrome 浏览器上进行调试。但需要帮助在应用程序上进行调试。我需要将 setWebContentsDebuggingEnabled 设置为 true,但我在哪里执行此操作?在 config.xml 中? developer.android.com/reference/android/webkit/…
-
我已经设法使用
ionic run android(即在我的android设备上运行的应用程序)使用设备进行调试。我可以访问和输出device对象的属性(uuid、模型等)。我的初始代码似乎一直没有任何问题,但问题似乎是当我通过 Ionic View 访问我的应用程序时,所有这些属性都是空白的。顺便说一句,不需要 platform.ready 行。