maui-platform-invoke

Invoke native APIs from shared MAUI code across Android, iOS, Mac Catalyst, and Windows.

Updated Dec 25, 2025
One-click install
npx skills add https://github.com/heldercsousa/MyVocaList --skill maui-platform-invoke-heldercsousa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: maui-platform-invoke
Source: https://github.com/heldercsousa/MyVocaList/tree/main/.claude/skills/maui-platform-invoke
Command: npx skills add https://github.com/heldercsousa/MyVocaList --skill maui-platform-invoke-heldercsousa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

MAUI projects often need to call platform-specific native APIs from shared code. Without structured patterns, this leads to scattered and hard-to-maintain code across Android, iOS, Mac Catalyst, and Windows.

Core Features & Use Cases

  • Partial classes to separate cross-platform logic from platform-specific implementations.
  • Conditional compilation and multi-targeting to access platform APIs safely across targets.
  • Dependency injection patterns to centralize platform-specific services and improve testability.

Quick Start

Create a cross-platform MAUI service interface and provide per-platform implementations, then register the service in MauiProgram for the target platform.

Frequently Asked Questions about maui-platform-invoke

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call platform-specific native APIs from shared .NET MAUI code?

To call native APIs from shared .NET MAUI code, you define a common interface and provide per-platform implementations for Android, iOS, Mac Catalyst, and Windows. You then use dependency injection to register and resolve the correct platform-specific service at build time.

What is the best way to structure cross-platform native API calls in MAUI?

The best way to structure cross-platform native API calls in MAUI is using partial classes and conditional compilation. This separates cross-platform logic from platform-specific implementations, ensuring safe access to native APIs across multiple targets without scattering code.

Does this MAUI platform invoke pattern support Android, iOS, Mac Catalyst, and Windows?

Yes, this MAUI platform invoke pattern explicitly targets Android, iOS, Mac Catalyst, and Windows. It uses multi-targeting and dependency injection to safely expose platform features through common interfaces across all supported operating systems.

How do I register platform-specific services in MauiProgram for native API access?

You register platform-specific services in MauiProgram by adding your cross-platform interface and its per-platform implementation to the dependency injection container. This allows the application to select and execute the correct native code path for the active platform at build time.

Why use dependency injection for MAUI native API calls instead of direct compilation directives?

Using dependency injection for MAUI native API calls centralizes platform-specific services and improves testability. Unlike relying solely on conditional compilation directives, dependency injection provides a clean architecture that keeps cross-platform logic decoupled from platform-specific implementations.

When should I use partial classes versus conditional compilation for MAUI platform invoke?

Use partial classes to cleanly separate cross-platform logic from platform-specific implementations, and use conditional compilation when you need to safely access platform APIs within multi-targeted files. Both patterns work together to maintain a clean architecture in .NET MAUI.