Table of Contents

Class NearbyConnectivity

Namespace
Plugin.Maui.NearbyConnectivity
Assembly
Plugin.Maui.NearbyConnectivity.dll

Provides the application-wide INearbyConnectivity instance for code that does not use dependency injection.

[SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "The root type is named after the plugin, the same way Plugin.Maui.* packages name theirs.")]
public static class NearbyConnectivity
Inheritance
NearbyConnectivity
Inherited Members

Remarks

Mirrors Geolocation.Default, Connectivity.Default and the rest of .NET MAUI Essentials. Applications that do use dependency injection should call AddNearbyConnectivity(IServiceCollection, Action<NearbyOptions>) and inject INearbyConnectivity instead. It is the same instance either way, so the two never disagree.

Configure before first use. ServiceId is required and has no default, so reading Default without having registered the service through the container throws. Call AddNearbyConnectivity(IServiceCollection, Action<NearbyOptions>) in MauiProgram, which every MAUI application has, and this property resolves from it.

Properties

Default

Gets the application-wide instance.

public static INearbyConnectivity Default { get; }

Property Value

INearbyConnectivity

The same singleton the dependency injection container hands out.

Exceptions

InvalidOperationException

Nearby connectivity has not been registered. Call AddNearbyConnectivity(IServiceCollection, Action<NearbyOptions>) in MauiProgram first.