Awesome
Microsoft.Maui.Platform.Channels
A simple bridge for messaging between .NET and iOS/MacCatalyst/Android Platforms at runtime
Getting Started
-
Install prerequisites:
- Install Xcode.
- Install Android Studio and JDK 17.
- Install the latest .NET 8 SDK and
maui
workload.
-
Build
Platforms
:dotnet build Platforms/build.proj
-
Build
Microsoft.PlatformChannels.sln
:dotnet build Microsoft.PlatformChannels.sln
-
Run the sample
dotnet build SamplePlatformChannels/SamplePlatformChannels.csproj -t:Run -f net8.0-android dotnet build SamplePlatformChannels/SamplePlatformChannels.csproj -t:Run -f net8.0-ios dotnet build SamplePlatformChannels/SamplePlatformChannels.csproj -t:Run -f net8.0-maccatalyst
ViewChannels
- Create your platform ViewChannel implementations using whatever platform specific code, libraries/sdks, etc. you like: https://github.com/Redth/Microsoft.Maui.Platform.Channels/blob/main/Platforms/Android/sample/src/main/java/com/microsoft/dotnet/platformchannels/sample/LabelViewChannel.java#L19-L23
- Reference your platform project from your .NET MAUI project: https://github.com/Redth/Microsoft.Maui.Platform.Channels/blob/main/SamplePlatformChannels/SamplePlatformChannels.csproj#L44
- Use the
PlatformChannelView
MAUI control to display your ViewChannel: https://github.com/Redth/Microsoft.Maui.Platform.Channels/blob/main/SamplePlatformChannels/MainPage.xaml#L17 - Send messages across to the platform: https://github.com/Redth/Microsoft.Maui.Platform.Channels/blob/main/SamplePlatformChannels/MainPage.xaml.cs#L18
- You can receive messages originating from the platform too: https://github.com/Redth/Microsoft.Maui.Platform.Channels/blob/main/SamplePlatformChannels/MainPage.xaml.cs#L48