maui-accessibility
Guide for making .NET MAUI apps accessible — screen reader support via SemanticProperties, heading levels, AutomationProperties…
Add geolocation capabilities to .NET MAUI apps using Microsoft.Maui.Devices.Sensors. Covers one-shot and continuous location, platform permissions (Android, iOS, macOS, Windows), accuracy levels, CancellationToken usage, mock-location detection, and a DI-friendly service
$ npx -y skills add davidortinau/maui-skills --skill maui-geolocation --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/maui-geolocationContext preview
The summary Claude sees to decide when to auto-load this skill.
Add geolocation capabilities to .NET MAUI apps using Microsoft.Maui.Devices.Sensors. Covers one-shot and continuous location, platform permissions (Android, iOS, macOS, Windows), accuracy levels, CancellationToken usage, mock-location detection, and a DI-friendly service
name: maui-geolocation description: > Add geolocation capabilities to .NET MAUI apps using Microsoft.Maui.Devices.Sensors. Covers one-shot and continuous location, platform permissions (Android, iOS, macOS, Windows), accuracy levels, CancellationToken usage, mock-location detection, and a DI-friendly service wrapper. USE FOR: "geolocation", "GPS location", "get current location", "location permission", "continuous location", "location tracking", "GeolocationRequest", "mock location", "latitude longitude MAUI". DO NOT USE FOR: displaying locations on a map (use maui-maps), general permission handling (use maui-permissions), or geocoding addresses (use maui-maps).
`GetLocationAsync` can hang indefinitely if GPS is off, the device is indoors, or permissions are in a pending state. Always set a timeout.
// ❌ Hangs forever if no GPS fix is available
var location = await Geolocation.Default.GetLocationAsync(
new GeolocationRequest(GeolocationAccuracy.High));
// ✅ Times out after 30 seconds
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var location = await Geolocation.Default.GetLocationAsync(
new GeolocationRequest(GeolocationAccuracy.High), cts.Token);---
Use the **lowest accuracy** that satisfies your feature. Higher accuracy drains battery significantly faster — especially on Android.
| Use case | Recommended accuracy | |---|---| | City-level / weather | `Lowest` or `Low` | | Nearby search / store finder | `Medium` | | Turn-by-turn navigation | `High` or `Best` |
---
Users can grant "approximate" location (accuracy > 1 km). Your app receives a location, but it may be useless for precision features.
`NSLocationTemporaryUsageDescriptionDictionary` in `Info.plist` to prompt for full accuracy.
// ⚠️ Always check in security-sensitive flows (e.g., geofence, check-in)
if (location.IsFromMockProvider)
{
// Reject — user is spoofing location
}Some Android devices return `0.0` for `Altitude` when the GPS has no barometric sensor. Treat `0.0` as **"unknown"**, not sea level.
`ACCESS_BACKGROUND_LOCATION` must be requested **separately** from foreground permissions and triggers a distinct system dialog. Requesting it together with foreground permissions causes both to be denied on some devices.
This is expected on first boot or after a location-data reset. Always fall back to `GetLocationAsync`:
// ✅ Cache-first with fresh fallback
var location = await geolocation.GetLastKnownLocationAsync();
if (location is null || location.Timestamp < DateTimeOffset.UtcNow.AddMinutes(-5))
{
location = await geolocation.GetLocationAsync(
new GeolocationRequest(GeolocationAccuracy.Medium, TimeSpan.FromSeconds(10)), ct);
}Call `Permissions.RequestAsync<Permissions.LocationWhenInUse>()` first, or catch `PermissionException`. Calling `GetLocationAsync` without permission throws on some platforms and returns `null` on others — inconsistent behaviour across platforms.
---
Failing to remove the `LocationChanged` handler when stopping causes continued GPS usage and battery drain.
// ❌ Forgetting to unsubscribe — GPS stays active
public void StopTracking()
{
Geolocation.Default.StopListeningForeground();
// LocationChanged handler still fires!
}
// ✅ Always remove the event handler
public void StopTracking()
{
Geolocation.Default.StopListeningForeground();
Geolocation.Default.LocationChanged -= OnLocationChanged;
}---
A collection of 41 skills for .NET MAUI development, UI/UX design reasoning, and Xamarin migration, designed for use with GitHub Copilot CLI and Claude Code.
Guide for making .NET MAUI apps accessible — screen reader support via SemanticProperties, heading levels, AutomationProperties…
.NET MAUI view animations, custom animations, easing functions, rotation, scale, translation, and fade effects. USE FOR: "animate…
.NET MAUI app icon configuration, splash screen setup, SVG to PNG conversion at build time, composed/adaptive icons, and…
.NET MAUI app lifecycle guidance covering the four app states (not running, running, deactivated, stopped), cross-platform Window…
Guide for .NET MAUI apps consuming .NET Aspire-hosted backend services. Covers AppHost configuration, service discovery for…
Add authentication to .NET MAUI apps. Covers WebAuthenticator for generic OAuth 2.0 / social login, and MSAL.NET for Microsoft…