2

In my app i want to get the device uuid or udid so that i can save it in my database.

for my android app when i run this code in my js file

.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

window.device.udid

it still doesnt work in my ios simulator. what can i do?

Kingsley Simon
  • 2,090
  • 5
  • 38
  • 84

2 Answers2

0

Solution 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

Solution 2 :

Use 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

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

I hope it will help you.

Community
  • 1
  • 1
0

but be aware, the UUID is not the same thing as the UDID. Differences between UDID and 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.

CompWitch
  • 44
  • 1
  • 5