React Native invoke mDNS endpoints - javascript

I am building an IOT device for my home and have mDNS responder on it (to avoid static IP setup for IoT devices).
Devices are to be controlled with React Native Android app, but the same seems to be not working and am getting Network error (using Axios).
My endpoints have changed from http://192.168.0.2/setSettings to http://mymdnstest.local/setSettings same works from windows chrome browser but not from android browser as well.
I came across zeroconf but it seems it searches for mdns URL but I am looking for more of invoking them.
Note: the mDNS endpoint is known to my React Native app.

Zeroconf actually works, the issue is with emulator it doesnt let us know if it works.. If you test it with physical device will get to know the mDNS details.

Related

Issue with react native app while logging in on android device

My react native app is functioning properly on emulator. But after generating apk version of the app, I could not log in to the app on android device.
What could be the possible solutions ? Please !!!
There are two possible situations
1- The API you are hitting is on HTTP you required HTTPS instead
you can enable the HTTP support as well check the link for details
How to allow all Network connection types HTTP
2- Android is blocking the API request for some reason change the device to test

How to check if any bluetooth device is connected in react native

I've been attempting to detect whether a bluetooth device is connected to an android phone once a button is clicked. If detected, I would like to interact with this device from within my app. The device I'm talking about is http://www.senanetworks.com/sd1000-01.html .
I've used the example code of https://www.npmjs.com/package/react-native-ble-manager to test it out, but unfortunately, it's not picking up this device even though the regular settings app does. Additionally, checking for already connected peripherals does not work if I connected to the device outside of the app. Any tips on how to do this?
The device you are using, the Parani-SD1000 Bluetooth Serial Adapter, does state in its specs that it uses Bluetooth 2.0. You are using a library for Bluetooth Low Energy devices, but BLE was only introduced with Bluetooth 4.0.
Your devices definitely uses Bluetooth Classic (also nown as Bluetooth Serial), thats also the reason why it shows up in the settings of your mobile phone. You need to use a library like react-native-bluetooth-serial. You can use the isConnected() method to detect wether or not it is connected.

Is there a way to remotely test react native?

I'm thinking to pass to a web app IDE like cloud9 to host my apps currently in development.
The problem with this is that i don't know how to test my code in the way I normally do with a simulator, locally.
I'm trying to develop on a remote server, and building on that remote server, an i want to test the app with my real device, with live reloading absolutely. If it's not possible to use my real device i could use an emulator and it's ok, but I'd prefer to use my phone.
I see you are using metro-bundler, you can achieve this by using the Tunnel option in connection:
This will create a global link to communicate with any of your devices. Then you can easily use the QR code or just the generated link in your own mobile device using expo app.
Now you can debug and test with your actual physical phone or emulator without publish it.

Can the Web NFC api be used in Progressive Web Applications?

I need to implement NFC (near field communication) in a PWA (progressive webapplication)
Every browser I have tested (Chrome MacOSX, Safari MacOSX, Safari iOS, Chrome for android) does not include the navigator.nfc object in navigator and it seems impossible to make use of this API: https://w3c.github.io/web-nfc/#conformance.
Is it possible to use NFC in any way in a PWA? Or do I have to develop a native application for this functionality?
Web NFC API is available only in Chrome for Android and that too when a flag is enabled(try about:flags) enabled.
Unless you are targeting your app for some internal corporate app where you can set the flag in all targeted users browser, I would recommend go with native code or wrapper(cordova or have a native app send in the details via web sockets)
This API is not making much progress since 2015 and so you can expect no magic to happen anytime soon. So don't rely on this API if you are targeting this for a critical app, especially when you cant control the end users browser settings.
From chrome 81 you can use NFC
https://blog.chromium.org/2020/02/chrome-81-near-field-communications.html

Get a tablets(iPad or Droid) mac address?

Synopsis: I am developing a HTML5 web app that will allow tablets(iPad or Droid) to login to a server and perform various functions. The client would like a way to check the devices mac address when logging in. From what I have read, most solutions use activex objects that will not work for webkit browsers.
Question: Does anyone know a solution that would hook into a HTML5 web app seamlessly(Idealy update a hidden form element with the value upon logging in)?
Thanks!
I don't think there's going to be a straightforward way to do this. The web server won't be exposed to a client's MAC address unless they're on the same physical segment...you'll only see the MAC from the most recent router hop in general.
If anything exists, it's going to be a browser plugin (show-stopper on iOS). And it would probably need more than the default permissions available (I don't suspect you can enumerate network interfaces in Java, for example, without asking for elevated permissions).
If you're looking for HTML/JS only then I don't think that this is possible. It won't be exposed.
The problem is that the packets you recieve back will only contain the MAC address of the node on the last hop.
This may be possible via a plugin, but then this limits you on iOS, and possibly also Android as you'd need to provide them a way of getting the plugin first (unless you used a plugin that was installed by default).
Edit: Not that I support an app for every little thing, but it shows that easy to press app buttons sometimes tend to do better than web apps (regardless of being able to make browser shortcuts to home screens). If it is suitable, you could consider loading this within a web view on the target device from within an app, from which you can then of course access MAC addresses and whatever else you may need.
MobiThinking: Mobile applications: native v Web apps – what are the pros and cons?
Forbes: Mobile Web App vs. Native App? It's Complicated

Categories