maui-platform-invoke

Call platform-specific native APIs from shared .NET MAUI code.

Updated Nov 5, 2025
One-click install
npx skills add https://github.com/mkazimoto/AppMAUICopilot --skill maui-platform-invoke
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: maui-platform-invoke
Source: https://github.com/mkazimoto/AppMAUICopilot/tree/main/.github/skills/maui-platform-invoke
Command: npx skills add https://github.com/mkazimoto/AppMAUICopilot --skill maui-platform-invoke

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Coordinating cross-platform MAUI apps with native platform capabilities can be verbose and error-prone. This Skill provides structured guidance to expose and call platform-specific APIs from shared code using partial classes, conditional compilation, multi-targeting configuration, and DI patterns for Android, iOS, MacCatalyst, and Windows.

Core Features & Use Cases

  • Cross-platform interop patterns: partial classes, conditional compilation, multi-targeting, and DI wiring.
  • Platform-specific implementations located under Platforms/{Platform} with shared interfaces in a clean separation.
  • Use Case: Build a service to access device features (camera, sensors) from common code while delegating to platform-specific implementations.

Quick Start

Create a cross-platform service interface and implement platform-specific logic in Platforms/Android, iOS, MacCatalyst, and Windows, then wire the implementations via DI so shared code can call native APIs.

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?▼

Call platform-specific native APIs from shared .NET MAUI code by using partial classes, conditional compilation, multi-targeting, and dependency injection to separate shared interfaces from platform-specific implementations under Platforms/{Platform}.

What is the best way to structure cross-platform interop in a .NET MAUI app?▼

The best way to structure cross-platform interop in .NET MAUI is defining a shared service interface in common code and placing platform-specific implementations under Platforms/Android, iOS, MacCatalyst, and Windows, wired via dependency injection.

Does this MAUI platform invoke approach support Mac Catalyst and Windows targets?▼

Yes, this MAUI platform invoke approach supports Android, iOS, Mac Catalyst, and Windows targets using multi-targeting configuration and conditional compilation to direct platform-specific API execution.

How do I use dependency injection to access device features like sensors in MAUI?▼

Use dependency injection to access device features in MAUI by registering platform-specific implementations of a shared interface, allowing shared code to call native APIs for sensors or cameras without direct platform dependencies.

When should I use conditional compilation versus partial classes for MAUI native API calls?▼

Use partial classes for clean separation of platform-specific implementations across multi-targeted projects, and use conditional compilation when you need to inline platform-specific logic within a shared file for native API calls.