-1

I am a newbie with ionic and trying to install phonertc on ionic platform but when i run the app it shows for VideoViewDirective that RefrenceError: cordova is undefined.

VideoViewDirective.js

angular.module('phonertcdemo')
  .directive('videoView', function ($rootScope, $timeout) {
return {
  restrict: 'E',
  template: '<div class="video-container"></div>',
  replace: true,
  link: function (scope, element, attrs) {
    function updatePosition() {
    cordova.plugins.phonertc.setVideoView({
        container: element[0],
        local: { 
          position: [240, 240],
          size: [50, 50]
        }
      });
    }

    $timeout(updatePosition, 500);
    $rootScope.$on('videoView.updatePosition', updatePosition);
  }
}
});
Bacteria
  • 8,406
  • 10
  • 50
  • 67

2 Answers2

0

I had the same issue when I first started. I made sure to declair com.dooble.phonert as a plugin. Then, I only referenced cordova.js in my index.html.

Hope this helps.

Jose Lopez
  • 73
  • 6
0

If you are running using ionic serve, it is expected to show cordova is undefined.

If you want to run it in browser, you should

ionic platform add browser
ionic run browser

Then you will be able to use part of cordova in your browser.

Li Siyao
  • 83
  • 9