Forum Xamarin.Forms

Notification to PCL when WiFi state changed?

Good afternoon everyone-

I have a quick (hopefully) question regarding receiving a state change notification for WiFi connectivity. The simple version: How do I get notification in my PCL that WiFi state has changed?

The complex version:
I have an app that would consume a huge amount of data if i let it, due to the size of the databases and the number of images that are displayed/added/updated (it's an inventory management application, before anyone yells at me about data usage :) ).

The use case came down from the bosses that data intensive should only work on WiFi connection - no option for cellular data. I've built out the dependency services for GetWiFiConnectivity, and that works just fine. What I'm doing is when I try to send a request over cell data, I pend it to a database until WiFi is connected, and then sync the data at that point.

So my question is this. I can check via the dependency service whether WiFi is enabled explicitly, but (using Android for the sake of brevity here:) is there a way I can receive, in my PCL, the notification from a broadcast receiver that the WiFi state has changed? i.e. fire an event handler or OnPropertyChanged when the broadcast receiver receives the notification that WiFi changed?

Thanks in advance, and I'm sorry if that's confusing...I can clarify if needed.

Best Answer


  • GeraldVersluisGeraldVersluis NLUniversity ✭✭✭✭
    edited September 2015

    I'm using the plugin mentioned by @Tekton as well.

    Documentation on GitHub is over here;

  • KyleMastersKyleMasters USMember ✭✭

    @Tekton and @GeraldVersluis - thanks a million. Not sure the couple hours I spent googling never turned this up, especially since i use a lot of Montemagno's plugins.

    Thanks! Working as expected.

Sign In or Register to comment.