Plugin.Maui.NearbyConnectivity 1.0.0-preview.1

This is a prerelease version of Plugin.Maui.NearbyConnectivity.
dotnet add package Plugin.Maui.NearbyConnectivity --version 1.0.0-preview.1
                    
NuGet\Install-Package Plugin.Maui.NearbyConnectivity -Version 1.0.0-preview.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Plugin.Maui.NearbyConnectivity" Version="1.0.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Plugin.Maui.NearbyConnectivity" Version="1.0.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="Plugin.Maui.NearbyConnectivity" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Plugin.Maui.NearbyConnectivity --version 1.0.0-preview.1
                    
#r "nuget: Plugin.Maui.NearbyConnectivity, 1.0.0-preview.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Plugin.Maui.NearbyConnectivity@1.0.0-preview.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Plugin.Maui.NearbyConnectivity&version=1.0.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Plugin.Maui.NearbyConnectivity&version=1.0.0-preview.1&prerelease
                    
Install as a Cake Tool

Plugin.Maui.NearbyConnectivity

NuGet Version NuGet Downloads CI Quality Gate Status Coverage License

Plugin.Maui.NearbyConnectivity provides the ability to discover, connect to, and exchange data with nearby devices that run your .NET MAUI application, without a server or an internet connection.

Features

  • Discovery. Advertise to nearby devices, and discover the devices that advertise the same ServiceId. Read them from Devices, or handle DeviceChanged.
  • Connection consent. Answer each inbound connection request with AcceptAsync or DeclineAsync, or call SetConsent to set a policy that answers for you. An unanswered request times out.
  • Bytes, files, and streams. Send byte payloads up to 32 KiB, files with progress reporting, and streams (experimental, opt in with NEARBY001). Receive payloads from every connection in one await foreach loop. Received files are staged in the app's cache directory until you move or dispose them.
  • Presence. Advertise a display name of up to 63 UTF-8 bytes and up to 57 bytes of app-defined data. Both are broadcast unencrypted to nearby devices before a connection exists.
  • Encrypted connections. Every connection is encrypted on both platforms. Each one exposes a six-digit AuthenticationCode that users compare out of band to detect a man-in-the-middle.
  • Bindable types. NearbyDeviceCollection implements INotifyCollectionChanged, and NearbySessionState implements INotifyPropertyChanged. Both raise their events on the UI thread, so XAML binds to them directly.
  • Permissions and availability. NearbyPermission works with Permissions.RequestAsync<T>() and covers every Android runtime permission the plugin needs. CheckAvailabilityAsync reports Bluetooth or Wi-Fi turned off, missing Google Play services, or a missing Info.plist entry.
  • Trimming and Native AOT. The library is compatible with both.
  • Logging. The plugin logs through ILogger with a stable EventId for each message. It registers no logging provider and sends no telemetry.

Supported platforms

Target Minimum Support
net10.0-android API 24 Requires Google Play services. Built on Nearby Connections.
net10.0-ios iOS 26.0 Built on Multipeer Connectivity.
net10.0 None Reference target for shared code and unit tests. CheckAvailabilityAsync returns NearbyAvailability.Unsupported, and StartAsync throws NearbyException.

No cross-platform connections. Android connects only to Android, and iOS only to iOS. On iOS, the plugin stops the session when the app enters the background. On Android, a connection lives as long as the process, so it survives backgrounding only if your app runs a foreground service. See Platform behavior.

Install

dotnet add package Plugin.Maui.NearbyConnectivity

Android needs no manifest changes. iOS needs two Info.plist keys. See Set up Android and iOS.

This package replaces Plugin.Maui.NearbyConnections. The 0.x previews under that name are deprecated and receive no fixes.

Usage

Register the plugin

Register the plugin in MauiProgram.cs. Devices discover each other only when they use the same ServiceId.

builder.AddNearbyConnectivity(options => options.ServiceId = "nearbyminimal");

AddNearbyConnectivity registers INearbyConnectivity as a singleton. Inject it, or use NearbyConnectivity.Default where constructor injection is not available. The same method exists on IServiceCollection for a host without a MauiAppBuilder, such as a unit test.

Request permission and start

Advertising and discovery do not start automatically.

if (await Permissions.RequestAsync<NearbyPermission>() != PermissionStatus.Granted)
{
    return;
}

nearbyConnectivity.Advertiser.SetConsent(NearbyConsentPolicy.AcceptAll);
await nearbyConnectivity.Advertiser.StartAsync();
await nearbyConnectivity.Discoverer.StartAsync();

AcceptAll accepts every inbound request without a prompt, so use it only in a demo. To prompt the user instead, see Accept and make connections.

Send a message

Pick a NearbyDevice from nearbyConnectivity.Devices, call ConnectAsync, and send on the returned NearbyConnection.

var connection = await device.ConnectAsync();
await connection.SendAsync("Hello"u8.ToArray());

Receive messages

PayloadsAsync merges the inbound payloads from every connection into one IAsyncEnumerable. The stream is single-consumer, so enumerate it in one place.

await foreach (var (sender, payload) in nearbyConnectivity.PayloadsAsync(cancellationToken))
{
    using (payload)
    {
        if (payload is NearbyBytesPayload bytes)
        {
            var text = Encoding.UTF8.GetString(bytes.Data.Span);
            Console.WriteLine($"{sender.Presence.DisplayName}: {text}");
        }
    }
}

These snippets follow samples/Minimal, the app from the Get started tutorial.

Documentation

Feedback and contributing

Issues and pull requests are welcome. See CONTRIBUTING.md. Ask questions in Discussions. Report bugs and request features with the issue forms.

Report vulnerabilities privately through SECURITY.md. Do not open a public issue.

Licensed under the MIT License.

Acknowledgements

This plugin started from Gerald Versluis's Plugin.Maui.Feature template.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.1 53 10/11/2026