I'm trying to build an ionic app for android and ios. In this app I need to send and receive udp packets to the server. For that I trying to use https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-sockets-udp
but i keep getting this error while running on a real device android device:
core.js:9110 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'bind' of undefined
TypeError: Cannot read property 'bind' of undefined
My code that causes this error is:
async broadcasting(messageSend)
{
this.platform.ready().then(
(readySource) => {
var udp = require('udp-packet');
chrome = window['chrome'];
if(readySource == 'cordova')
{
const pack = udp.encode({
sourceIp: '10.0.0.1',
sourcePort: 58936,
destinationIp: '85.214.60.74',
destinationPort: 7810,
data: new Buffer(messageSend)
});
(<any>window).chrome.sockets.udp.bind(123445, pack,'85.214.60.74',7810, function(result){
console.log("result bind",result);
});
chrome.sockets.udp.send(123445, pack,'85.214.60.74',7810, function(result){
console.log("result send",result);
});
chrome.sockets.udp.onReceive.addListener(function(result){
console.log("result listener",result);
});
}
});
}
Any idea on what I'm doing wrong?
I ended up finding that I only had tcp plugin installed, I had to run "cordova plugin add cordova-plugin-chrome-apps-sockets-udp" to make it work.