Ionic Cordova设备UUID [英] Ionic Cordova Device UUID
问题描述
您好,我正在使用Ionic框架和Cordova开发混合应用程序。我想使用设备uuid作为ID,所以我已经添加了cordova设备插件。此外,我使用NG-Cordova包装调用我的cordova插件。但是每当我在xcode模拟器中运行我的应用程序或在一个实际的Ipad上,我得到的是{{uuid}}。
Hi i am developing a hybrid app using the Ionic framework and Cordova. I am looking to use the device uuid as an ID so i have added the cordova device plugin. Additionally i am using the NG-Cordova wrapper for calling my cordova plugins. However whenever i run my app in the xcode Simulator or on an actual Ipad all i get is {{uuid}} .
似乎没有任何错误信息i只能假设设备插件不工作。
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?
控制器:
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
<ion-view title="Dashboard">
<ion-content class="padding">
<h1>Dash</h1>
{{uuid}}
</ion-content>
</ion-view>
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.
如果我只是正常或Minified版本的ngcordova它完美地工作。
if i just the normal or Minified version of ngcordova it works perfectly.
感谢您的帮助。
这篇关于Ionic Cordova设备UUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!