Hello,
MAUI officially provides a way to detect connectivity.
You could use the following code to alert users when the network is limited or when they lose connection.
//Add this line of code to the page's constructor
Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;
void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
{
if (e.NetworkAccess == NetworkAccess.ConstrainedInternet)
DisplayAlert("Warning", "Internet access is available but is limited.", "OK");
else if (e.NetworkAccess != NetworkAccess.Internet)
DisplayAlert("Warning", "Internet access has been lost.", "OK");
}
Please refer to the Connectivity for more information.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.