Cannot Get UUID (device id) - IONIC 1

Friends,

I need help getting device id (UUID). I tried to find it several days.I read so many different forum topics. I read many web pages. I looked so many tutorials. I tried so many different way, and I can’t get the device id.

My current way (ref):

In controllers.js

.controller('PageCtrl', function($ionicPlatform, $scope, $cordovaDevice) {
    $ionicPlatform.ready(function() {
        $scope.$apply(function() {
            // sometimes binding does not work!
 
            // getting device infor from $cordovaDevice
            var device = $cordovaDevice.getDevice();
 
            $scope.manufacturer = device.manufacturer;
            $scope.model = device.model;
            $scope.platform = device.platform;
            $scope.uuid = device.uuid;
 
        });
 
    });
})

I already did these following steps:

  • ionic cordova plugin add cordova-plugin-device
  • npm install --save @ionic-native/device
  • ionic cordova run ios

Note: I exported the code from ionic Creator (v1). I have added ionic native javascript along with ng-cordova as well. I also added [‘ngCordova’] to angular.module.

I need ionic native javascript for my geolocation. It works with geolocation.

Please advise.

Thank you

Do you want to use ngCordova (which was made for Ionic v1) or Ionic Native (which most versions only work with Ionic 2+)?

1 Like

I got device id now. I found out that ngCordova and ionic.native are interfere each other.

To answer your question, I prefer ngCordova.

Right now, I am able to get device id (uuid) with ionic 1 & ngCordova. I am also able to get geolocation (sometime - on and off). So, I think I will remove ionic.native, and use ngCordova to get device id & geolocation.

Please advise if I head to the right direction.

Thank you so much.

Sounds like a good decision if it works for you.

Can they use along with one another? (ngCordova & ionic.native)

No idea.

Your problem will be to find a working Ionic Native for Ionic v1, I think support was dropped with 3.x.
ngCordova is full compatible with Ionic v1.

1 Like