Implementing Feature

This feature won't be enable by default for optimization reasons. For using the feature, we must initialise the component.

On every change in network connectivity detected, NetworkConnectivity.NetworkConnectivityChangedEvent event is fired. So, make sure you register to this event a head.

This initialisation starts monitoring the mentioned server address for connectivity.

NPBinding.NetworkConnectivity.Initialise();

This fetches the current connection status. Returns true if server is reachable.

NPBinding.NetworkConnectivity.IsConnected();

On every change in connection status, NetworkConnectivity.NetworkConnectivityChangedEvent is triggered. If you want to notify user when network is lost, you can just register to this event and receive the callback.

void OnEnable ()
{
// Register to event
NetworkConnectivity.NetworkConnectivityChangedEvent += NetworkConnectivityChangedEvent;
}
void OnDisable ()
{
// Deregister to event
NetworkConnectivity.NetworkConnectivityChangedEvent -= NetworkConnectivityChangedEvent;
}
void NetworkConnectivityChangedEvent(bool _isConnected)
{
Debug.Log ("Is Connected : " + _isConnected);
}