Platform integration


Use native platform features in project templates:

Overview
In the bit platform, you have the ability to use JavaScript features across all operating systems (except during Prerendering).
Additionally, there's access to Java and Kotlin capabilities in Android, and Swift and Objective-C in iOS and macOS. C# .NET itself has good access to Windows OS features.
If you wish to use JavaScript, write the relevant function in app.ts and call it using JSRuntime. There are some examples in the project template, for example, for reading and writing in the cookie.
Dependency injection sample
Suppose we plan to read contacts on Android and iOS and save and sync them to the server. In the Windows, macOS and web versions, we'll fetch and display them from the server.

First define an interface named IContactsService in the src\Client\Boilerplate.Client.Core/Services/Contracts and implement it separately in the following locations:
src/Client/Boilerplate.Client.Maui/Platforms/Android named AndroidContactsService
And
src/Client/Boilerplate.Client.Maui/Platforms/iOS named iOSContactsService

Then register them in the following locations:
src/Client/Boilerplate.Client.Maui/Platforms/Android/Extensions/IServiceCollectionExtensions
services.AddTransient<IContactsService, AndroidContactsService>();
src/Client/Boilerplate.Client.Maui/Platforms/iOS/Extensions/IServiceCollectionExtensions
services.AddTransient<IContactsService, iOSContactsService>();
In each platform folder you've access to all native platform features!
Implement that interface once more in src\Client\Boilerplate.Client.Core/Services/ that leverages http client to get synced contacts from the server, and register that in src/Client/Boilerplate.Client.Core/Extensions/IServiceCollectionExtensions
services.TryAddTransient<IContactsService, AndroidContactsService>();
Using TryAdd, we're registering that service for all app models, unless one of them registers another implementation with Add instead of TryAdd. So Web, Windows and macOS versions of the app are using this shared implementaion that gets synced contacts from the sever, but Android and iOS have their own implementations.
Sample code:
src/Client/Boilerplate.Client.Core/Services/Contracts
public class ContactData
{
    public string Name { get;set; }
}

public interface IContactsService
{
    Task<List<ContactData>> GetContactData();
}
src/Client/Boilerplate.Client.Maui/Platforms/Android/Contracts
public class AndroidContactsService : IContactsService
{
    public async Task<List<ContactData>> GetContactData()
    {
        // here you've access to all android platform features!

        var uri = ContactsContract.Contacts.ContentUri!;

        string[] projection = {
           ContactsContract.Contacts.InterfaceConsts.Id,
           ContactsContract.Contacts.InterfaceConsts.DisplayName,
           ContactsContract.Contacts.InterfaceConsts.PhotoId,
        };

        // Whenever you need android's context, just use MauiApplication.Current

        var cursor = MauiApplication.Current.ContentResolver!.Query(uri, projection, null, null, null);

        // save contacts to the server's database

        // return contacts
    }
}
Native UI (Xaml)
Lastly, you might want to use Xaml Controls, like the well-known MediaElement from the Maui Community Toolkit.
In this case, inject IPubService on your razor page, publish a message, and inject IPubSubService in the constructor of the MainPage class in src/Client/Boilerplate.Client.Maui/MainPage.xaml.cs.
Then subscribe to the relevant key and display your new Xaml page using App.Current.MainPage.PushAsync.
Advanced scenarios
If needed, for using Kotlin, Swift, Objective-C, or Java libraries, you can utilize .NET MAUI Binding Libraries. This tool helps you have a C# Wrapper for your Kotlin, Java, Swift, Objective-C library, giving you full access.
For further advanced scenarios, you can integrate Blazor content with XAML controls or even display Native controls created in Kotlin or Swift.
There are interesting resources online. For instance, an article showcases how to display SwiftUI controls in your iOS project.
You can also place a razor page once in the web project and once in the app project with the same route, but different C# codes. The appropriate page will be displayed at runtime!