Usage
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.
Table of Contents
Import Namespaces
using VoxelBusters.EssentialKit;
using VoxelBusters.CoreLibrary;Understanding Network Monitoring
Two Monitoring Types
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:
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:
Data Properties
NetworkServicesInternetConnectivityStatusChangeResult.IsConnected
bool
true when the device currently has a route to the internet (Wi-Fi, cellular, etc.).
NetworkServicesHostReachabilityStatusChangeResult.IsReachable
bool
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.
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
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
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:
Related Guides
Demo scene:
Assets/Plugins/VoxelBusters/EssentialKit/Examples/Scenes/NetworkServicesDemo.unityUse with Task Services to ensure critical uploads complete before backgrounding
Pair with offline-first data architecture for seamless connectivity transitions
See Testing Guide for network simulation and device validation
Last updated
Was this helpful?