Native integrations for .NET applications, through one reusable bridge.
NativeChannels connects C# with Kotlin, Swift, and Windows APIs through asynchronous calls, messages, event streams, and embedded native views. Keep SDK operations in a native adapter and expose a typed C# API to your application. Each operation travels through the generic bridge without a method-specific C# binding.
With a native module registered, inject IChannelService and call its named operations:
using var channel = channels.GetMethodChannel("sample");
string? reply = await channel.InvokeAsync<string>("echo", "Hello from .NET");
// The bundled Kotlin or Swift sample adapter returns "Hello from .NET".Preview software. NativeChannels supports Android, iOS, Mac Catalyst, and Windows through its MAUI integration. The core messaging layer is independent of MAUI. The latest published preview is 0.3.0-preview.1, available for MAUI, Avalonia and Uno. The exact release packages passed the existing Interop channel and native-view checks across all 16 supported framework/platform combinations. Reference plugin packages are excluded. See the verification record and preview limitations.
Documentation · Getting started · Build a plugin · Examples
| Contract | API | Reference example |
|---|---|---|
| Named operations with typed results and structured errors | MethodChannel |
Currency: currency code → native symbol |
| Values or binary chunks with an asynchronous reply | BasicMessageChannel |
AudioStreamer: PCM playback through AudioTrack / AVAudioEngine / Windows waveOut |
| Native observations with independent subscriptions | EventChannel |
VolumeMonitor: volume levels and listener cleanup |
| Embedded native UI with an instance-specific channel | PlatformChannelView |
PdfViewer: PDFKit / PdfRenderer / Windows.Data.Pdf with navigation and zoom |
All four examples include native adapters and a separate MAUI application that consumes local packages. They are reference implementations for plugin authors. Start with the channel selection guide to choose a contract for your integration.
C# application or plugin
↕ named channels
NativeChannels messenger + codecs
↕ platform transports and generic bindings
Kotlin, Swift, or Windows C# adapter
↕
Native SDK
Both sides agree on names and supported values. The messenger handles requests, correlation, cancellation, and timeouts; codecs encode the payloads. Native modules register explicitly at startup. Native code can also call C# and await a reply.
An integration can live inside your application or in a reusable plugin containing its C# facade, native adapters, and package imports. The consuming application then configures the plugin once. NativeChannels supplies the communication layer; you still provide native SDK dependencies and platform-specific lifecycle behavior. See architecture.
Choose the optional NativeChannels.Maui or NativeChannels.Avalonia package for your
application's startup, UI dispatch, and native view integration. For messaging alone,
reference NativeChannels and use services.AddNativeChannels(...), managing service
ownership and UI dispatch in your application. See package boundaries.
The Currency, AudioStreamer, and VolumeMonitor plugins are framework-independent.
The experimental Uno host follows the same optional boundary;
try its local package samples with the documented limitations.
Add the package to a .NET 10 MAUI application:
dotnet add package NativeChannels.Maui --version 0.2.0-preview.1Core, platform transports, and the applicable Android or Apple binding are transitive dependencies.
Windows support is included in NativeChannels and NativeChannels.Maui. You still provide and
register the native adapter for your SDK; installing the bridge alone does not add SDK operations.
For Avalonia, reference NativeChannels.Avalonia and the platform package NativeChannels;
see the Avalonia host guide.
The getting-started guide walks through package installation, adapter registration, and a complete native round trip. Then follow one path:
- Browse MAUI samples: see the sample applications.
- Try the bridge: run the ChannelExplorer sample.
- Integrate a native SDK: follow getting started, then the Android and Apple adapter guides.
- Build a reusable plugin: follow plugin authoring and study the Currency reference implementation.
Repository samples use local feeds to test source changes. For those feeds, device commands, and the pinned toolchain, see building from source.
- Independent ownership. Disposing a channel handle cancels its calls and removes its registrations; other handles for the same endpoint remain usable.
- Async communication. Incoming handlers enter in FIFO order; their replies may complete out of order. Reentrant native-to-managed calls are supported.
- Explicit deadlines. Requests default to 30 seconds. Override per service, channel, or call;
Timeout.InfiniteTimeSpandisables the timer. Cancellation signals cooperative remote cancellation. - Typed values. The default tagged JSON codec preserves signed integers, bytes, lists, and maps.
DTOs use configured
System.Text.Jsonmetadata, including source-generated contexts for trimmed builds. - Bounded streams. Every event enumeration owns a subscription. Its default buffer holds 64 values and fails explicitly on overflow; optional drop policies are available.
- View lifecycle. Every connected native view has its own instance and method channel. Reconnecting creates a new instance and invalidates the old channel. View operations require the UI thread.
See configuration, lifecycle, and error handling for the detailed contracts.
| Platform | Integration |
|---|---|
| Android | Kotlin/Java adapters and native Android views |
| iOS | Swift/Objective-C adapters and UIKit views |
| Mac Catalyst | Apple adapters and UIKit views on macOS |
| Windows | C# adapters for WinRT, COM, and native libraries; WinUI views |
MAUI is the published 0.1 application host. Mac Catalyst support does not provide an AppKit desktop host. Unreleased Avalonia 0.2 and experimental Uno 0.3 work target Android, iOS, Windows, desktop macOS, Linux, and browser/WebAssembly. See platform verification for executed scenarios and Uno release gates for its remaining runtime, native-view and PDF gaps. Development work does not extend the published support matrix.
| Task | Guide |
|---|---|
| Make your first native call | Getting started |
| Choose calls, messages, streams, or views | Choose a channel |
| Package an integration for other applications | Build a plugin |
| Configure codecs, DTOs, timeouts, and dispatch | Codecs · Configuration |
| Diagnose startup or runtime failures | Troubleshooting |
| Log channel timings and outcomes | Diagnostics |
| Explore the public C# surface | API reference |
The documentation website includes searchable guides, native examples, and a complete index.
The portable solution needs no mobile workloads:
bash eng/bootstrap.sh
bash eng/dotnet.sh test -c ReleaseUse eng/NativeChannels.Platforms.slnx for platform libraries. Changes to native bridges, bindings,
dependencies, or packaging require fresh package-consumer verification.
See contributing, testing, and performance.
The roadmap covers the initial preview, complete Avalonia and Uno integration, including the experimental Uno host package with per-window sessions and UI dispatch, and stable API acceptance. The development Avalonia host package provides application registration, owned sessions and UI dispatch. The template-generated Avalonia solution contains Avalonia Android, Avalonia iOS, Avalonia Windows, Avalonia native macOS, Avalonia Linux, and Avalonia Browser, covering the Currency method-call slice of the milestone. Use the release checklist before distribution.
Pull requests run portable tests and compile affected platforms using one shared Core build. Use Verify framework for development checks and Verify distribution to assemble final packages and test their consumers before distribution. Example plugins and benchmarks remain separate, optional workflows; see CI commands. Verification workflows do not publish packages. The separate manual NuGet publishing workflow defaults to a dry run and requires approval to publish.
MIT. Inspired by Flutter platform channels and Redth's MAUI platform channels.