How to check the internet speed in my ionic app?

I am trying to get the internet connection speed and show it in my app with an icon of the wifi.
I am using ‘ng-speed-test’, to get the test speed. Still, I am having a problem with Safari and iOS, not updating the navigator.onLine when I turn off the wifi on my MacBook, while Chrome updates it successfully, safari return navigator.onLine to ‘true’ again:

const checkOnlineStatus = () => {
      console.log('checkOnlineStatus 🧨🧨🧨', navigator.onLine);
    // Periodically check the online status every 5 seconds

Is there any way I can check the connection status and its speed, it needs to work on all platforms (Web and iOS).

Thanks in advance,