Open TechWithRamaa opened 9 years ago
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).
Hi,
I was able to use this in my Ionic application by referencing chrome.sockets.udp.
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...
Are you checking that chrome is defined in the $ionicPlatform.ready callback? It should be in your module.run function.
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?
Nice... Waiting for deviceready before using the plugin works for me! Thanks.
@nutella Can you please paste your code here for reference?
You can look at: https://github.com/nutella/ionic-cordova-chrome-udp-example
NICE! :)
Thanks!!!
How to integrate this into Angular or Ionic application?