Network change state not getting detected in Release mode background - Xamarin.iOS

91 Views Asked by At

In my application, I have used Xamarin.Essentials to detect network changes in background & fire notifications based on network availability. The code works perfectly on the device & simulator during Debug. However, the Xamarin.Essentials fail to detect connectivity changes in Release mode, especially in the background. The events get triggered when the application reenters into the application (when application becomes ro foreground)

Following is the code I have used

    CrossConnectivity.Current.ConnectivityChanged += Current_ConnectivityChanged;
    private void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)

    {
                if (_networkService.IsConnected())
                {
                    ShowBannerNotificaiton("Internet", "Available", "data1");
                }
                else
                {
                    ShowBannerNotificaiton("Internet", "Not Available", "data2");                     
                }
        }

Appreciate the solution given

0

There are 0 best solutions below