Change the method used in order to detect the device's network connection #72
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think you should consider changing the way you detect the device's internet connection. As I understood reading by your code, the application does not detect when the device has lost network connection until it makes another service call. Then, it starts calling the service every 3 seconds in a loop until the connection is back.
This behavior could affect the performance of the app, as it will constantly be trying to make new network calls until the user has a network connection again. Besides, it is a good practice to notify the user when the device has lost internet connection, instead of only showing a loading page.
Therefore, I recommend you use the connectivity plugin to detect the connection status via a stream. With this new plugin, you should be able to detect when the user has lost/gained an internet connection and update the UI accordingly. Likewise, the app will be able to pause network and service calls until a stable connection returns.
The pull request I made shows how to make use of this plugin, by showing a “No Network Connection” message in the home page whenever the device has lost internet connection
Please take into account that the translation updates did not work for me, nor did I have the chance of testing the code on an iOS device.
Hope this can come in handy to you guys.
Warm regards,
Sergio Yepes