How to check connection in Intel XDK - intel-xdk

My app need to detect if the device is connected to the internet or not. To do this I'm using the below script:
document.addEventListener("intel.xdk.device.connection.update",function(){
if(intel.xdk.device.connection == "none")
{
alert("Offline");
} else {
alert("Online");
}
},false);
intel.xdk.device.updateConnection();
This code work perfectly in the emulator, but not in my Moto G, using Intel XDK Preview tool or after install the apk generated using Cordova!
Didn't show any fail message, just do nothing!

Once you added Cordova Network plugin, you can detect network details as:
function checkConnection() {
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection';
alert('Connection type: ' + states[networkState]);
}
checkConnection();
Following links explain how to use Intel-xdk bridge to call different APIs
Intel XDK Cordova API Documentation
Intel XDK "legacy" API Documentation
Apache Cordova* API Documentation
https://software.intel.com/en-us/html5/xdkdocs#506911
Intel XDK Name Space API Plugin Details for Cordova Build Containers
Note that the APIs listed below augment the standard Cordova APIs, both APIs can and should be used in your application. In some cases there is overlap between the Cordova APIs and the intel.xdk APIs; in that case, we recommend you use the Cordova API first and then use the intel.xdk API when the Cordova API either does not provide the desired functionality or provides inadequate functionality.
Check this out, it will help you configure the plugin: Understanding the IntelĀ® XDK Cordova Build Options

Related

How can I get android id using ADB and within Unity application?

I need to get the AndroidID using ADB and inside the unity application check if it's the same device using the AndroidID.
With this command, using ADB I have the AndroidID:
adb shell settings get secure android_id
>> a9822db857e4****
And inside the unity application, I'm using this code:
AndroidJavaClass clsUnity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject objActivity = clsUnity.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject objResolver = objActivity.Call<AndroidJavaObject>("getContentResolver");
AndroidJavaClass clsSecure = new AndroidJavaClass("android.provider.Settings$Secure");
string android_id = clsSecure.CallStatic<string>("getString", objResolver, "android_id");
>> android_id = 98ff3a034b16****
You may notice that the IDs are different.
Does anyone have a solution for this?
How can I get that same identifier using ADB and in unity ?
If your device runs Android version > Android 8.0 (API level 26), the ANDROID_ID string is unique to each app (more precisely, to each app-signing key - so more like unique to all your apps you signed with the same key). You can check out all the changes related to ANDROID_ID here.
If you are running Android version < 8.0, you might have multiple users and they will have separate ids - maybe you are getting root users' id via ADB and the whatever-user-launched-your-app id from code? (See here).

iOS 14 gives "OS Error: Bad file descriptor, errno = 9" when doing local network broadcasting

Doing a little Jeopardy style Q&A here.
I'm developing an app in Flutter that uses the udp package for broadcasting on the local network. This has worked fine on Android, Windows, macOS and iOS until I tried on an iOS 14.6 device.
The code flow is mainly like this:
var endPoint = Endpoint.broadcast(port: Port(6000));
var udpFuture = UDP.bind(Endpoint.any(port: Port(6000)));
udpFuture.then((udp) {
udp.listen((datagram) {
handleMessage(datagram.data);
});
udp.send(bytesToSend, endPoint);
}
The error message I'm getting is this: Unhandled Exception: OS Error: Bad file descriptor, errno = 9
Starting from iOS 14 your app needs the Multicast networking entitlement com.apple.developer.networking.multicast to be able to send or receive IP multicast traffic.
To get the entitlement you need to apply using Apple's request form. It took me 4-5 days before I got the request approved.
Then you can follow the instructions on Apple's forums to get up and running.

Connect to embedded Printer in a PDA device

I am developing a flutter app to print receipt from a PDA device. The device is an Android 6.0 and has built in printer. I am trying to figure out how to connect to the printer to send printing command through esc_pos_printer https://pub.dev/packages/esc_pos_printer flutter package. However, what I found only through Network or Bluetooth.
const PaperSize paper = PaperSize.mm80;
final profile = await CapabilityProfile.load();
final printer = NetworkPrinter(paper, profile);
final PosPrintResult res = await printer.connect('192.168.0.123', port: 9100);
do you have any idea to connect to the printer

Issues with Flutter and Phoenix Channels

We're having some issues with our Flutter App and Pheonix Web Sockets. We know that the Backend is working properly, since the JavaScript client is fully functional. But with the Flutter app we can't connect to the server.
final socket = PhoenixSocket("ws://###.##/socket");
connectSocket() async {
await widget.socket.connect();
_channel = widget.socket.channel("test:lobby")
_channel.on("say", _say);
_channel.join();
}
One of the errors were gettig:
I/flutter ( 4227): WebSocket connection to ws://###.##:8080/socket?vsn=2.0.0 failed!: WebSocketException: Connection to 'http://###.##:8080/socket?vsn=2.0.0#' was not upgraded to websocket
On the client side we're using Phoenix Wings, the port and URL are correct.
Why does this keep happening?
Are there any other libraries for Flutter with Phoenix Interactions?
Is there a better documentation for phoenix_wings or for any other packages?
I had it working as
final socket = PhoenixSocket("ws://####.###/socket/websocket");
hth.

Parameters were incorrect when running Selenium?

I'm testing my app on mac with real ios device. When i run the scripts it says following error in Eclipse IDE,
org.openqa.selenium.SessionNotCreatedException: Unable to create new
remote session. desired capabilities = Capabilities
[{app=/Users//Downloads/XXX.ipa,
platformVersion=10.2.1, platformName=iOS, deviceName=Mr.x'S iPod touch,
UDID=*****}], required capabilities =
Capabilities [{}]
Then i checked the logs in appium it shows,
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were
incorrect. We wanted {"required":["desiredCapabilities"],"optional":
["requiredCapabilities","sessionId","id"]} and you sent [
"desiredCapabilities" , "requiredCapabilities", "capabilities",
"alwaysMatch","firstMatch"]
What should i do to fix this, Can anyone help me to resolve this.
Yes, you need xcode to access iOS native app.
Desired capabilities to be used:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "9.3");
capabilities.setCapability("deviceOrientation", "portrait");
capabilities.setCapability("browserName", "Safari");
capabilities.setCapability("autoWebview", "true");
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("deviceName", "iphone");
capabilities.setCapability("autoAcceptAlerts",true);
capabilities.setCapability("udid", UDID);
capabilities.setCapability("xcodeConfigFile", "/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Config.xcconfig");
capabilities.setCapability("realDeviceLogger","/usr/local/lib/node_modules/deviceconsole");