2.0 Unified Background Events
React Native Nitro Geolocation 2.0 routes provider status and iOS Core Location
lifecycle changes through onBackgroundEvent. A single subscription now
observes every background event kind.
On Android and iOS, each subscription receives its own initial
providerChange snapshot. Later provider changes are delivered once per active
subscriber. Removing a subscription removes its provider watcher as well, so a
direct getProviderStatus() call can return a newer value without changing
removed event counters. Web background listeners remain no-op subscriptions and
do not emit an initial provider snapshot.
Provider snapshots are live-only and are not stored. iOS lifecycle events are
stored when the background configuration has persistence enabled, matching
location, geofence, activity, and HTTP sync events. Android does not synthesize
Core Location lifecycle events.
Migrate lifecycle listeners
onLocationLifecycleChange() remains as a convenience API, but in 2.x it is a
filter over the unified stream rather than a separate native listener channel.
Existing call sites can remain unchanged:
The behavior is still observational. A pause does not automatically restart tracking, and start/stop calls do not fabricate lifecycle events.
Update exhaustive event handling
BackgroundEvent now includes the lifecycle discriminant. Add that case to
exhaustive switches before upgrading. The native-only
addLocationLifecycleListener and removeLocationLifecycleListener methods
are no longer part of the generated Nitro contract; application code should
use the public functions above.
