简体   繁体   English

获取设备 uuid 离子 ios 应用程序

[英]get device uuid ionic ios app

In my app i want to get the device uuid or udid so that i can save it in my database.在我的应用程序中,我想获取设备 uuid 或 udid,以便我可以将其保存在我的数据库中。

for my android app when i run this code in my js file当我在我的 js 文件中运行此代码时,对于我的 android 应用程序

.factory('Service', function($state) {
  var service = {
    login: function(user, new_device_status) {
      if(window.cordova) {
        var params = {
          organization: user.orgCode.$modelValue,
          email: user.email.$modelValue,
          password: user.password.$modelValue,
          device_uuid: window.device.platform == 'Android' ? window.device.uuid : window.device.udid,
          new_device: new_device_status
        };
     }
   }
  }
})

it works and returns the uuid of the device but in my ios app when i try this it doesnt work or when i try它可以工作并返回设备的 uuid 但在我的 ios 应用程序中,当我尝试此操作时它不起作用或当我尝试时

window.device.udid

it still doesnt work in my ios simulator.它在我的 ios 模拟器中仍然不起作用。 what can i do?我能做什么?

Solution 1 :解决方案1:

Add device plugin :添加设备插件:

cordova plugin add org.apache.cordova.device

In your controller :在您的控制器中:

module.controller('MyCtrl', function($scope, $cordovaDevice) {
  var uuid = $cordovaDevice.getUUID();
});

Answer from : How to get the device UUID in ionic framework答案来自: 如何在离子框架中获取设备 UUID

Solution 2 :解决方案2:

Use IDFVPlugin :使用 IDFVPlugin :

cordova plugin add https://github.com/jcesarmobile/IDFVPlugin.git

In your controller :在您的控制器中:

 window.IDFVPlugin.getIdentifier(function(result){ 
    alert(result); 
},function(error){ 
    alert(error); 
});

Sources :来源:

https://github.com/jcesarmobile/IDFVPlugin https://github.com/jcesarmobile/IDFVPlugin

http://forum.ionicframework.com/t/how-to-get-iphone-unique-id-udid-in-ionic-framework-script/9575 http://forum.ionicframework.com/t/how-to-get-iphone-unique-id-udid-in-ionic-framework-script/9575

I hope it will help you.我希望它会帮助你。

but be aware, the UUID is not the same thing as the UDID.但请注意,UUID 与 UDID 不同。 Differences between UDID and UUID UDID 和 UUID 的区别

the UUID is the app specific id that changes when you remove the app or update it sometimes even, and the UDID is the unique id from the phone itself. UUID 是特定于应用程序的 ID,它会在您删除应用程序或有时甚至更新它时发生变化,而 UDID 是手机本身的唯一 ID。

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

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