D Donkeh docs
GitHub

Host permissions

Donkeh.Hosting.Host exposes the current platform and awaitable permission requests. The framework supplies desktop, Android and browser providers, so application code uses one API everywhere.

Platform flags

using Donkeh.Hosting;

if (Host.IsAndroid)
{
    // Android-only setup.
}

if (Host.IsDesktop || Host.IsWeb)
{
    // Shared responsive path.
}

Console.WriteLine(Host.PlatformName);
MemberTrue when
Host.IsAndroidRunning on Android.
Host.IsIOSRunning on iOS.
Host.IsWindowsRunning on Windows.
Host.IsMacRunning on macOS.
Host.IsLinuxRunning on Linux.
Host.IsWebRunning in a browser.
Host.IsBrowserAlias for IsWeb.
Host.IsDesktopWindows, macOS or Linux, excluding the browser.
Host.IsMobileAndroid or iOS.
Host.PlatformNameA friendly name such as Web or Windows.

Requesting a permission

Every permission method returns Task<bool> and accepts an optional CancellationToken.

using Donkeh.Hosting;

if (await Host.Permissions.Camera())
{
    // Open the camera.
}
MethodCapability
Camera()Camera capture.
Microphone()Audio capture.
Location()Current location.
Notifications()System notifications.
Photos()Photo library / images.
Storage()File storage access.
Contacts()Contacts.
Calendar()Calendar.
Bluetooth()Nearby Bluetooth devices.
Motion()Motion or activity data.
Clipboard()System clipboard.

A known permission can also be requested through the enum: Host.Permissions.Request(HostPermission.Camera).

Behaviour

Platform providers

HostProvider
DesktopDefault grants access and lets the device API fail if the OS has blocked it.
AndroidRequests runtime permissions from the activity and completes from OnRequestPermissionsResult.
BrowserUses getUserMedia, geolocation, Notification, Storage, DeviceMotion and Clipboard APIs.
iOS / unsupportedReturns false until a host installs a provider.
Browser user gestures Camera, microphone and notification requests should be started from a click or key handler. Browsers block or ignore permission prompts that do not come from a user gesture.

Android manifest

The app can let the framework generate the matching uses-permission entries. Add the permission tokens to the project file:

<PropertyGroup>
  <DonkehAndroidPermissions>Camera;Microphone;Location;Notifications</DonkehAndroidPermissions>
</PropertyGroup>

Supported tokens are Camera, Microphone, Location, Notifications, Photos, Storage, Contacts, Calendar, Bluetooth and Motion. The framework emits the entries into the merged Android manifest. You can still use a hand-written manifest if you prefer.

The framework also adds INTERNET automatically when the app’s stylesheets contain a remote @import or url(...). Remote imports (icon fonts, for example) are fetched by the native host at start-up, and release APKs do not receive INTERNET implicitly the way debuggable builds do. Set DonkehAndroidInternet to auto (the default), true or false to override detection.

Custom providers

A host can replace the permission provider during startup. Implement IPermissionService and install it before mounting the app:

using Donkeh.Hosting;

public sealed class MyPermissionService : IPermissionService
{
    public Task<bool> RequestAsync(
        HostPermission permission,
        CancellationToken cancellationToken = default)
    {
        // Ask the platform, then return true or false.
        return Task.FromResult(false);
    }
}

Host.UsePermissions(new MyPermissionService());

Host.UsePermissions(null) restores the desktop default. Calling it clears cached grants so a new platform session starts clean.

One API for all hosts Keep permission checks in event handlers and other user-driven paths. The same Host.Permissions call works on desktop, Android and the browser without platform-specific #if blocks in application code.