简体   繁体   English

离子Cordova设备UUID

[英]Ionic Cordova Device UUID

Hi i am developing a hybrid app using the Ionic framework and Cordova. 嗨,我正在使用Ionic框架和Cordova开发混合应用程序。 I am looking to use the device uuid as an ID so i have added the cordova device plugin. 我希望使用设备uuid作为ID,所以我添加了cordova设备插件。 Additionally i am using the NG-Cordova wrapper for calling my cordova plugins. 另外,我正在使用NG-Cordova包装器来调用我的cordova插件。 However whenever i run my app in the xcode Simulator or on an actual Ipad all i get is {{uuid}} . 但是,每当我在xcode Simulator或实际的Ipad上运行我的应用程序时,我得到的都是{{uuid}}。

There does not seem to be any error message i can only assume that the Device Plugin is not working. 似乎没有任何错误消息,我只能假定设备插件不起作用。

i have put my code below however im not sure this is the issue, Has anyone had this issue before and if so how did they work around it? 我将我的代码放在下面,但是我不确定这是问题所在,是否有人之前曾遇到过此问题,如果可以,他们是如何解决的?

Controller: 控制器:

angular.module('starter.controllers', []).controller('DashCtrl', function(
$scope, $state, $cordovaDevice) {
var init = function() {
    console.log("initializing device");
    try {
        $scope.uuid = $cordovaDevice.getUUID();
    } catch (err) {
        console.log("Error " + err.message);
        alert("error " + err.$$failure.message);
    }
};
init();

}) })

Html HTML

<ion-view title="Dashboard">
  <ion-content class="padding">
    <h1>Dash</h1>
    {{uuid}}
  </ion-content>
</ion-view>

app.js app.js

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
    .run(function($ionicPlatform) {
        $ionicPlatform.ready(function() {
            if (window.cordova && window.cordova.plugins.Keyboard) {
                cordova.plugins.Keyboard.hideKeyboardAccessoryBar(
                    true);
            }
            if (window.StatusBar) {
                // org.apache.cordova.statusbar required
                StatusBar.styleDefault();
            }
        });
    }).config(function($stateProvider, $urlRouterProvider) {
        $stateProvider
        // setup an abstract state for the tabs directive
            .state('tab', {
                url: "/tab",
                abstract: true,
                templateUrl: "templates/tabs.html"
            })
            // Each tab has its own nav history stack:
            .state('tab.dash', {
                url: '/dash',
                views: {
                    'tab-dash': {
                        templateUrl: 'templates/tab-dash.html',
                        controller: 'DashCtrl'
                    }
                }
            });
        // if none of the above states are matched, use this as the fallback
        $urlRouterProvider.otherwise('/tab/dash');
    });

the reason behind my issue was due to using a custom build of ngCordova. 我的问题背后的原因是由于使用了自定义的ngCordova构建。

if i just the normal or Minified version of ngcordova it works perfectly. 如果我只是ngcordova的普通版或压缩版,它会完美地工作。

Thanks for all the help. 感谢您的所有帮助。

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

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