Network Services monitors internet connectivity and server reachability on mobile devices
Essential Kit wraps native iOS and Android network monitoring APIs into a single Unity interface. Network Services provides real-time connectivity detection with automatic change notifications.
Network Services provides two independent monitoring capabilities:
Internet Connectivity: Monitors general internet access via WiFi, cellular, or other connections. Use this to detect when the device is completely offline.
Host Reachability: Monitors connectivity to a specific server or service. Use this to detect when your backend is unreachable even if general internet is available.
Monitoring Lifecycle
Network monitoring must be explicitly started and can be stopped to conserve battery:
StartNotifier(): Begin monitoring and receiving change events
StopNotifier(): Stop monitoring to save battery
Auto Start: Optionally enable in settings to start monitoring automatically on app launch
Event Registration
Register for connectivity events in OnEnable and unregister in OnDisable:
Event
Trigger
OnInternetConnectivityChange
Fired when general internet connectivity status changes (online/offline)
OnHostReachabilityChange
Fired when configured host server reachability changes (reachable/unreachable)
Starting Network Monitoring
Why Monitoring is Needed
Detect connectivity changes in real-time to provide immediate feedback to players about network status. This allows you to:
Block online features when offline
Queue actions for when connectivity returns
Show appropriate UI (offline indicators, retry buttons)
Prevent frustrating network error dialogs
Basic Monitoring
Checking Current Status
Once monitoring is started, check the current network status anytime without waiting for events:
Indicates whether the configured host responded to Essential Kit’s reachability probe.
NetworkServices.IsInternetActive
bool
Last known internet status; stays cached until you start the notifier or a new change event fires.
NetworkServices.IsHostReachable
bool
Live view of backend reachability. Returns true until a reachability check fails or host monitoring is disabled.
NetworkServices.IsNotifierActive
bool
Confirms whether monitoring is currently running, which is useful before registering UI states or retry queues.
Status properties are only refreshed while the notifier is active. Start monitoring before reading them to avoid stale defaults.
Stopping Network Monitoring
Stop monitoring when network status isn't needed to conserve battery:
Battery Optimization: Stop monitoring when not needed (menu screens, pause screens, background state). Restart when entering online-dependent gameplay or features.
Practical Implementation Patterns
Blocking Online Features When Offline
Queueing Actions for When Connectivity Returns
Handling Server-Specific Failures
Smart Monitoring Control
Core APIs Reference
API
Purpose
Returns
NetworkServices.StartNotifier()
Begin network connectivity monitoring
void - events fire on status changes
NetworkServices.StopNotifier()
Stop network monitoring to save battery
void
NetworkServices.IsInternetActive
Check current internet connectivity
bool
NetworkServices.IsHostReachable
Check current host server reachability
bool
NetworkServices.IsNotifierActive
Check if monitoring is currently running
bool
Error Handling
Scenario
Trigger
Recommended Action
No host reachability events
OnHostReachabilityChange never fires
Confirm a host address (and optional port) is set in Essential Kit Settings before starting the notifier.
Immediate disconnects after Start
Monitoring started but properties stay true
Ensure StartNotifier() is called before reading status properties and that you’re subscribed to events in OnEnable.
Rapid event flapping
Device switches quickly between Wi-Fi and cellular
Debounce repeated status changes before toggling UI or retry queues (see snippet below).
Long-running monitoring drains battery
Notifier left active on offline screens
Stop the notifier on menus or pause screens and restart only when online functionality is required.
Debounce Example
Missing Host Configuration
Advanced: Manual Initialization
Manual initialization is only needed for specific runtime scenarios. For most games, Essential Kit's automatic initialization handles everything. Skip this section unless you need dynamic host configuration or runtime settings.
Understanding Manual Initialization
Default Behavior: Essential Kit automatically initializes Network Services using the settings asset configured in the Unity Editor.
Advanced Usage: Override default settings at runtime when you need:
Dynamic host address based on user region or environment
Server-driven monitoring configuration
A/B testing different polling intervals
Feature flags for network monitoring
Implementation
Override settings at runtime before starting monitoring:
Call Initialize() before calling StartNotifier(). Most games should use the standard setup configured in Essential Kit Settings instead.
void OnInternetConnectivityChange(NetworkServicesInternetConnectivityStatusChangeResult result)
{
if (result.IsConnected)
{
// Enable online features
multiplayerButton.interactable = true;
leaderboardButton.interactable = true;
eventButton.interactable = true;
Debug.Log("Hide offline banner.");
}
else
{
// Disable online features
multiplayerButton.interactable = false;
leaderboardButton.interactable = false;
eventButton.interactable = false;
Debug.Log("Show offline banner: No internet connection.");
}
}
private Queue<System.Action> pendingActions = new Queue<System.Action>();
void SavePlayerProgress()
{
if (NetworkServices.IsInternetActive)
{
// Upload immediately
Debug.Log("Upload progress to the server.");
}
else
{
// Queue for later
pendingActions.Enqueue(() => Debug.Log("Deferred upload to server."));
Debug.Log("Action queued - will execute when online");
}
}
void OnInternetConnectivityChange(NetworkServicesInternetConnectivityStatusChangeResult result)
{
if (result.IsConnected && pendingActions.Count > 0)
{
Debug.Log($"Connection restored - executing {pendingActions.Count} queued actions");
while (pendingActions.Count > 0)
{
pendingActions.Dequeue().Invoke();
}
}
}
void OnHostReachabilityChange(NetworkServicesHostReachabilityStatusChangeResult result)
{
if (!result.IsReachable)
{
// Backend down but internet available
if (NetworkServices.IsInternetActive)
{
Debug.Log("Show maintenance dialog: Our servers are temporarily unavailable. Please try again later.");
}
else
{
Debug.Log("Show offline dialog: No internet connection. Please check your network settings.");
}
}
else
{
Debug.Log("Hide maintenance dialog and resume server operations.");
}
}
enum GameState
{
MainMenu,
Multiplayer,
Leaderboards,
LiveEvents,
SinglePlayer,
}
void OnGameStateChanged(GameState newState)
{
switch (newState)
{
case GameState.MainMenu:
// Menu doesn't need constant monitoring
NetworkServices.StopNotifier();
break;
case GameState.Multiplayer:
case GameState.Leaderboards:
case GameState.LiveEvents:
// Online features need active monitoring
NetworkServices.StartNotifier();
break;
case GameState.SinglePlayer:
// Single player can stop monitoring
NetworkServices.StopNotifier();
break;
}
}