Xamarin.Form Check for Internet connection

We use the Xam.Connectivity.Pluggin to check if internet connection change.

I was wondering if it’s possible to have an Event PreCallClientRequest(…) we can register to so we can pass the status of the internet connection and decide to cancel the call so we don’t have the exception.

I think we can subclass the client to do so but maybe it’s also good for other project…

What strategy other people use ? Any Advice…


You can’t just cancel a request, any pending requests would need to return a response or throw an Exception. You can use a RequestFilter to throw an Exception otherwise you would need to do your pre-check before making the Service request. Instead of inheriting the ServiceClient, I’d instead look at implementing the IServiceClient interface to wrap a ServiceClient similar to how CachedServiceClient is implemented.

1 Like