Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

how to use this in Angular Ionic application #5

Open
TechWithRamaa opened this issue Aug 10, 2015 · 9 comments
Open

how to use this in Angular Ionic application #5

TechWithRamaa opened this issue Aug 10, 2015 · 9 comments

Comments

@TechWithRamaa
Copy link

How to integrate this into Angular or Ionic application?

@jnsat
Copy link

jnsat commented Sep 16, 2015

I also want to know. I tried doing it like this

angular.module('key', ['ionic'])
//.factory('udpfact')
.controller('keyctrl', ['$scope', 'chrome', function($scope, chrome) {
  //nothin
}])
  .run(function($ionicPlatform, $timeout) {
    alert("runnin");
    $ionicPlatform.ready(function() {
      alert('window.cordova: ' + Object.keys(window.cordova).join(', '));
      alert('window.cordova: ' + Object.keys(window.cordova.plugins).join(', '));
      alert(JSON.stringify(window.cordova));
      alert(JSON.stringify(window.cordova.plugins));

      alert("printed windows.cordova");
      $scope.sendcmd = function sendcmd(cmd) {
        alert("cmd: " + cmd);
        chrome.sockets.udp.create({}, function(socketInfo) {
          var socketId = socketInfo.socketId;
          chrome.sockets.udp.send(socketId, cmd,
            '10.0.0.9', 2390, function(sendInfo) {
              alert("sent " + sendInfo.bytesSent);
          });
        });
      };
  });
});

But it only shows one plugin (keyboard).

@digitalcatnip
Copy link

Hi,

I was able to use this in my Ionic application by referencing chrome.sockets.udp.. Don't use 'window.cordova.plugins' .

@nutella
Copy link

nutella commented Sep 30, 2015

I've added this plugin with ionic plugin add, then I need to load any js or is automatic? Because if I try to run a sample app, I always get that chrome is not defined... What's wrong?
Thanks...

@digitalcatnip
Copy link

Are you checking that chrome is defined in the $ionicPlatform.ready callback? It should be in your module.run function.

@jnsat
Copy link

jnsat commented Sep 30, 2015

Hi digitialcatnip,
Thank you for your info. I am using chrome.sockets.udp. The plugin lines were to print a list of plugins loaded. It did not show chrome. Oh, so are you saying chrome should be passed to run and not controller?

@nutella
Copy link

nutella commented Oct 1, 2015

Nice... Waiting for deviceready before using the plugin works for me!
Thanks.

@rohit-gandhe
Copy link

@nutella Can you please paste your code here for reference?

@nutella
Copy link

nutella commented Mar 30, 2017

You can look at:
https://github.com/nutella/ionic-cordova-chrome-udp-example

@rohit-gandhe
Copy link

NICE! :)

Thanks!!!

yvni added a commit to yvni/cordova-plugin-chrome-apps-sockets-udp that referenced this issue Apr 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants