dotnet/maui-labs/maui-platform-invoke
Claude Code and agent skill by dotnet/maui-labs
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Add native platform APIs through MAUI services and lifecycle hooks. USE FOR: DI wrappers, permissions, AndroidManifest.xml, Info.plist, entitlements, partial platform files, `ConfigureLifecycleEvents`, choosing services vs handlers vs bindings. DO NOT USE FOR: visual handlers, native SDK bindings, backend.
Install
npx vskill@latest install dotnet/maui-labs/maui-platform-invokeSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as dotnet/maui-labs/maui-platform-invoke.
MAUI Platform Invoke
Use this skill when a MAUI app needs platform APIs that are not already exposed by a cross-platform MAUI API. Prefer small, testable abstractions over scattered #if blocks.
Response Checklist
- Define a DI abstraction first (for example
IAppReviewService) and inject it
into app services or view models.
- Mention required permission flow and platform metadata files
(AndroidManifest.xml, Info.plist, capabilities/entitlements).
- Put lifecycle guidance in
ConfigureLifecycleEvents(AddAndroid,AddiOS,
AddWindows) instead of page constructors.
Choose the Right Extension Point
| Need | Prefer | |
|---|---|---|
| Existing cross-platform Essentials API covers it | Microsoft.Maui.ApplicationModel, Devices, Storage, etc. | |
| Non-visual platform API or OS service | DI interface with per-platform implementation | |
| Native view/control behavior | Handler mapper or custom handler | |
| Platform lifecycle callback | ConfigureLifecycleEvents | |
| Third-party SDK with many native types | Slim binding plus a narrow app service | |
| One small compile-time constant | #if or OnPlatform |
Platform Service Pattern
- Define an interface in shared code:
``csharp public interface IAppReviewService { Task RequestReviewAsync(CancellationToken cancellationToken = default); } ``
- Implement it per platform using target-specific files:
``csharp // Platforms/Android/AppReviewService.android.cs public sealed class AppReviewService : IAppReviewService { public Task RequestReviewAsync(CancellationToken cancellationToken = default) { // Call Android APIs or a bound SDK here. return Task.CompletedTask; } } ``
- Register only the platforms that have implementations in
MauiProgram.cs:
``csharp #if ANDROID builder.Services.AddSingleton<IAppReviewService, AppReviewService>(); #endif ``
When adding iOS, Mac Catalyst, Windows, or MAUI Labs AppKit support, add the matching platform implementation file first and then extend the guard, for example #if IOS || MACCATALYST or #if MACOS.
- Inject
IAppReviewServiceinto view models or application services. Keep page
constructors simple.
Partial Classes and Conditional Compilation
- Prefer platform-specific files under
Platforms/<Platform>/for code that
imports native namespaces.
- Use
partialclasses when one cross-platform type needs per-platform method
bodies.
- Use
#if ANDROID,#if IOS,#if MACCATALYST,#if IOS || MACCATALYST,
#if MACOS, and #if WINDOWS intentionally. iOS and Mac Catalyst often share UIKit APIs, but AppKit macOS does not.
- Avoid
Device.RuntimePlatformfor behavior that can be decided at compile
time.
Permissions and Capabilities
Before calling a platform API:
- Check whether MAUI has a
Permissions.*helper for the capability. - Add required manifest, Info.plist, entitlements, or package declarations.
- Request permission from UI-safe code before invoking the service.
- Handle denied/restricted states explicitly and surface user-actionable
recovery instructions.
Do not swallow permission failures or return fake success. In a service layer, return a result such as PermissionStatus or bool and let the caller surface the denial in UI.
Lifecycle Hooks
Use lifecycle hooks when the native API depends on app/window lifecycle:
Keep lifecycle code small. Forward work into registered services when state must be shared with view models.
Validation Checklist
- A cross-platform interface isolates native API calls.
- Platform implementation files compile only for their intended target.
- Required permissions, manifests, plist entries, entitlements, or capabilities
are documented and added.
- Denied permissions are handled explicitly.
- Native lifecycle subscriptions are paired with cleanup where applicable.
- Visual customization is not implemented as a generic platform service.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/dotnet-maui/skills/maui-platform-invoke/SKILL.md
Popularity
- Repository stars
- 224
- Repository forks
- 35
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dotnet/maui-labs/maui-platform-invoke)