2

I have an Ionic 3 App that has lot of http request on a server. I also want to detect how fast or slow the connection of the user is depending on his/her connection.

For example like in the Spotify and Messenger App that they can detect slow connections of the user.

I tried using ionic/network but the downlinkMax property always returns null. Tested on browser and Android device.

Here is the code below.

async initializeApp() {
 await this.platform.ready()
  console.log(this.network.downlinkMax) // always returns null
}

I also tried this solution but this is not an accurate measure of the speed if the network is too fast as they have said and it may also affect the performance of the app due to another request.

Any other thoughts?

Apreciate if someone could help. Thanks in advance.

KnowledgeSeeker
  • 1,058
  • 2
  • 19
  • 44

2 Answers2

0

The documentation says that you have to wait before making a request

Try something like this

this.network.onConnect().subscribe(() => {
  console.log('network connected!');
  setTimeout(() => {
      console.log(this.network.downlinkMax);
  }, 3000);
});
Ruben Sala
  • 271
  • 1
  • 10
0

I know this is an old question but to save anyone else's sanity, the downlinkMax property will always return null as it is never assigned a value in the plugin. Please see the comment here

Daniel Douglas
  • 3,283
  • 1
  • 16
  • 17