如何在基于离子的App中获取设备的uuid和型号信息? [英] How to get the device's uuid and model information in ionic based App?

查看:76
本文介绍了如何在基于离子的App中获取设备的uuid和型号信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码是为了识别/获取设备信息.

I have this piece of code in order to recognize/get the device information.

ionic.Platform.ready(function() {
    // will execute when device is ready, or immediately if the device is already ready.
    $scope.deviceInformation = ionic.Platform.device();
    $scope.currentPlatform = ionic.Platform.platform();
    $scope.currentPlatformVersion = ionic.Platform.version();
});

按照此处给出的文档进行操作. ionic.Platform.device(); 将返回由cordova返回的对象.因此,在cordova对象中,该对象应包含uuid,版本,模型等信息.文档为

as per the documentation given Here. The ionic.Platform.device(); will return object that is returned to it by cordova. So in the object of cordova the object should contain information of uuid, version, model etc. The documentation is Here

因此,我尝试从对象 deviceInformation 中获取uuid和模型,并构建并在移动设备中看到了该应用程序,然后在警报中向我显示了 undefined .

So i tried to get the uuid and model from the object deviceInformation and built and seen the app in mobile, then it shows me undefined in the alert.

我已经这样显示了:

$scope.getDeviceInfo = function() {
    alert($scope.deviceInformation.uuid);
}

我如何获取将科尔多瓦放回离子系统的物体的详细信息?

How can i get the details of object returned my cordova to ionic??

推荐答案

我遇到了同样的问题.经过长时间的搜索->尝试->实现->擦除->新的尝试周期,我得到了您需要的东西.尽管我遵循ng-cordova插件,但我知道添加ng-cordova.js并不会使解决插件问题变得容易,因为它仅包含ng-cordova网站上支持的插件的初始化.我已按照给出的步骤在本地cordova网站上找到

I was suffering with the same problem. I got what you need after long search->try->implement->erase->new try cycle. Though i followed ng-cordova plugins, i came to know that adding ng-cordova.js will not make it easy to resolve the plugin problem bcoz it just contain the initialization of plugins that are supported by the ng-cordova on its website. I have followed the steps given Here on native cordova site

这里要注意的是ng-cordova.js在内部调用方法和API的od native cordova,因此即使在安装ng-cordova.js之后也要分开安装cordova插件,这一点非常重要.然后,我在 app.module 中初始化了设备:

Point to note here is ng-cordova.js internally calls the methods and API's od native cordova so it is very important to install the cordova plugins separately even after you install the ng-cordova.js. Then i initialized the device in app.module:

$ionicPlatform.ready(function() {
  $scope.deviceInformation = ionic.Platform.device();
});

然后我在介绍控制器中调用了该方法:

and i called the method in my intro controller:

$scope.getDeviceInfo = function() {
  alert($scope.deviceInformation.uuid);
}

那给了我所有我需要的东西....

That gave me all that i need....

这篇关于如何在基于离子的App中获取设备的uuid和型号信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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