Hello, i wanted to know if there’s a way to check if the current device is connected to a network via blueprints? or if there’s a way in C++ i don’t mind, it’s just that i don’t know that much of C++.
I’ve found a way but read that it was a solution for windows, so in case you need it, i’m most interest in learning this for mobile ( Android & IOS)
This is what i’ve found:
if(InternetCheckConnection(L"http://www.google.com",FLAG_ICC_FORCE_CONNECTION,0))
{
cout << "connected to internet";
}
Ok so i figured it out, at least for mobile. There’s a blueprint node called “Connect to service” which returns an execution pin indicatend if it succeeded to connect or if it failed, one could use said node to know if the device is connected to a network.
Show External Login UI will bring up Google Play Service / IOS log in screen when you run it on a published game service. It’s probably not what you’re looking for.
@Niyo_official
Hi, HasActiveWiFiConnection is the most relevant node (I’m using BP) I’ve found, but it always returns me false on the android device, weither I’m connected or not (via 4g+). Do you know if there is something else to do? I’m trying via “launch” maybe it works only for downloaded app?
thanks
I know this is an old thread, but I thought I’d chime in with a solution in case others come here as I hadn’t found a method as clean as what I have established in my project.
There is a free plugin call VaRest, i came across this plugin while trying to access and pull JSON API data from the net, for my purpose i wanted to get real world time to store on game exit, then compare to the time when app reopened.
In the attached image you can see how I implemented the network check.
I take the VaRest subsystem, construct a JSON object then use the “Call URL” function, from here i have the URL that gives the JSON data from the worldclockapi.
Then from the call back I have the event which contains the request variable that holds the data received from the URL, from there you can “Get Status”, then switch on the enum giving you outs for different results from the request. The key one here is obviously “Succeeded” being the device is online and made connection to the URL and “Failed” or “Failed Connection Error” meaning the URL connection failed.
I believe “Failed” can occur if simply the URL is wrong or currently unavailable so connection error type would be a safer bet if simply attempting to get internet connection status.
I have yet to actively try this on a mobile device, but it works on PC and because of the functionality I can’t see why it would not work on mobile devices.
Hope this helps someone else looking for a solution!
If there is no Network connection the Custom Event (NetworkTest Response) will not trigger at all, you’ll only get some info in the Output Log
If the Network works - it will trigger the Custom Event as intended
Hi I am currently struggling to get this to work properly I need to keep a check on the status of the internet connection throughout game play not just on event begin play does any one have a clean example of how this can be done with this plugin through blueprint preferable a screen shot of the codes