onReceive events are raised when UDP packets arrive on the address/port specified.
The function UDPonReceive is never called. Does the listener code need to be modified for iOS?
We decided to try some of the other UDP apps.
We’re having a lot of trouble getting Apple phones to work with any of the available UDP plugins so far. It always works with Android but get errors for Apple.
For example, i get this error when i press Button1 as below using an iPhone (using https://www.npmjs.com/package/cordova-plugin-socket-tcp) Error connecting - [NSTaggedPointerString stringValue]: unrecognised selector sent to instance 0x98a6c4a0c5d57b
and the code is below (need to press button 1)
var socket;
document.addEventListener("deviceready", Main2, false);
function Main2()
{
}
Button1.onclick = function()
{
if(typeof(cordova) != "undefined") //running in PhoneGap
{
socket = new Socket();
socket.open(ipadd.value, portval.value, GG1, GG2);
}
else //running in browser
{
NSB.MsgBox("Running in browser")
}
};
function GG1()
{
Label1.value = "Successfully connected";
socket.onData = function(data) {
// invoked after new batch of data is received (typed array of bytes Uint8Array)
//NSB.MsgBox("onData - " + JSON.stringify(data))
Label1.value = "onData - " + JSON.stringify(data);
};
socket.onError = function(errorMessage) {
// invoked after error occurs during connection
//NSB.MsgBox("onError - " + JSON.stringify(errorMessage))
Label1.value = "onError - " + JSON.stringify(errorMessage);
};
socket.onClose = function(hasError) {
// invoked after connection close
//NSB.MsgBox("onClose - " + JSON.stringify(hasError))
Label1.value = "onClose - " + JSON.stringify(hasError);
};
}
function GG2(errorMessage)
{
Label1.value = "Error connecting - " + JSON.stringify(errorMessage);
};
With android, i get “Successfully connected”.
Does Apple need some special treatment in the config file or something else?
I couldn’t get onReceive calls to work with another plugin but it works with android.