Ive Used The “internet connectivity” Extension But It does not Work On Any Other Device Aside From PC . So I Wanted To Know If There Is Any Other Way To Check If A Device Is Connected To Internet Whether Its Through Wi-fi Or Mobile Data.
There is one extension do this just Looking
Internet connection
Or in easy words
Check if device is Mobile
Check is device is connected to wifi
@Phoenix I already tried that it doesn’t work for some reason just to make things clear it’s mostly mobile data I use to connect to the web
I think it doesn’t work in the preview. You need to do a build (apk)
I use that to check for connection on PC it works on PC but does not work on mobile that’s the problem I’ve been trying to talk about
When i was working for internet provider in my town
He was checking if newly connected PC by cable have internet
By opening command prompt
And pinging google.com
I would assume one way or another it would be possible with javascript
Maybe you should google that or ask on gdevelop discord javascript channel for help
Where i would assume you would only need to check if anything was returned from site in some time frame
I wonder if multiplayer with THNK have something there that would do what you want
I won’t even pretend i understand anything THNK related
BUUUUUUUUUUUUUT maybe it is checking are you connected to something one way or another?
If so that would be only part you need from it
Even better i wonder could you use firebase for that
Like retrieve some data from it and that would be your indication of is device online or not?
I am really NOT into online stuff that all i wrote above is just me assuming stuff where it most likely is BS
Maybe ask in multiplayer channel on discord?
Maybe there someone would have some hacky way?
I tested this JavaScript, and it seems to work. First, you need to create a global variable named INTERNETAVAILABLE
.
// Funzione per impostare la variabile globale
function setInternetStatus(status) {
console.log("Impostando INTERNETAVAILABLE su: " + (status ? "TRUE" : "FALSE"));
runtimeScene.getGame().getVariables().get("INTERNETAVAILABLE").setString(status ? "TRUE" : "FALSE");
}
// Funzione per verificare la connessione a Internet tramite fetch
function isInternetAvailable() {
return fetch('https://www.google.com/', { mode: 'no-cors' })
.then(() => {
console.log("Fetch riuscito");
return true;
})
.catch((error) => {
console.log("Fetch fallito:", error);
return false;
});
}
// Verifica lo stato della connessione a Internet
isInternetAvailable().then((available) => {
setInternetStatus(available);
});