Finally, we did a javascript action to calculate the time that takes the app to download a image from internet, it returns a boolean with false value if the time is over 2500 mlsec:
export async function ACT_IsGoodConnection(maxTimeConn) {
// BEGIN USER CODE
const maxTimeGoodConnection = Number(maxTimeConn);
const startTime = Date.now();
return Promise.race([
fetch('YOUR_FILE_TO_DOWNLOAD')
.then(response => {
const endTime = Date.now();
const totalTime = endTime - startTime;
return totalTime < maxTimeGoodConnection;
}),
new Promise((_, reject) => setTimeout(() => reject('Timeout'), maxTimeGoodConnection))
])
.catch(error => {
return false;
});
The parameter is a costant where you can choose the time that you can consider slow.
Regards.