$cordovaDevice plugin not working in Ionic View App


#1

I’ve installed ngCordova’s Device plugin

cordova plugin add cordova-plugin-device

But trying to access the device is not working from the Ionic View App. From the following code, nothing is alerting.

I’ve read from here that the cordova device plugin should be compatible with Ionic View. Have I missed something?

angular.module('myApp', ['ngCordova'])
    .run(function($ionicPlatform, $cordovaDevice) {
         $ionicPlatform.ready(function() {
             alert($cordovaDevice.getUUID());
         });
    })

#2

maybe this one can help you out ;]
http://ngcordova.com/docs/plugins/device/


#3

Yes that’s where I got the documentation for the device plugin. As it says on the page $cordovaDevice.getUUID() should return a string of the device’s UUID. It seems, at least in my situation, it doesn’t return anything in Ionic View.


#4

I’ve just created a completely fresh project. I installed ngCordova and its Geolocation plugin and I got it to alert() my location in Ionic View. Worked fine. Then I installed ngCordova’s Device plugin. Trying to alert my UUID within Ionic View fails again.

Any ideas why it just seems that ngCordova’s Device plugin isn’t playing nicely with Ionic View? Has anyone had success with this?


#5

Did u only try on Ionic serve ?

If yes, you can probably can see that device is not defined when you check console log on your browser(F12)
and this one might help you out,


#6

Thanks, but I’m trying to get this to work with Ionic View, I know that cordovaDevice will not work in the desktop browser.


#7

Similar issue with my app. Following link works fine for me. http://thejackalofjavascript.com/getting-started-with-ngcordova/


#8

Thanks for the link, that’s a very thorough document. I’ll try it out and see if I can get it to work.


#9
$ionicPlatform.ready(function() {        
         $scope.$apply(function() {            
                 // sometimes binding does not work! 
          var device = $cordovaDevice.getDevice();           
     
               });   
        });

I think $scope.$apply is making a difference.


#10

I am facing the same problem and is driving me nuts! Did someone solve this?


#11

I’m having same problem with “Ionic View”. Has anyone tried with Facebook plugin? Note the OP is specifically referring to using the mobile app “Ionic View” on their device. Not ionic serve or anything local on their machine for development. This is a mobile app for previewing Ionic developed apps without having to install your application directly onto device but test it from the cloud. I could be wrong but I would guess Ionic View only supports the changes HTML JS content and anything native would have to be preinstalled with Ionic View. Geolocation and others that can use the HTML5 specs as fallback may still work but what about other Cordova plugins?