.NET MAUI › Platform Integration & Handlers

How do you invoke platform APIs that have no MAUI abstraction, cleanly?

Advanced

Answer

Define a shared interface, implement it per platform (Platforms folder partial classes), and register in DI. This keeps native calls isolated and testable via the interface, unlike scattering #if throughout business logic. It's the recommended pattern for features like biometric auth or platform-specific storage.
public interface IBiometricAuth { Task<bool> AuthenticateAsync(string reason); }
// Platforms/iOS/BiometricAuth.cs -> LAContext
// Platforms/Android/BiometricAuth.cs -> BiometricPrompt
builder.Services.AddSingleton<IBiometricAuth, BiometricAuth>();
Real-world example Face ID and Android BiometricPrompt sit behind one IBiometricAuth so the login view model calls a single method.

Common follow-ups: Why an interface over #if? | How does this help testing?