Skip to main content

ServiceCollectionExtensions

Namespace: BlazorNative.Device

Registration for the BlazorNative.Device capability façades. Call ServiceCollectionExtensions.AddBlazorNativeDevice(IServiceCollection) from your DI setup so a component doing [Inject] IGeolocation (and its siblings) resolves the façade over whichever IMobileBridge the host registered.

public static class ServiceCollectionExtensions

Inheritance ObjectServiceCollectionExtensions
Attributes ExtensionAttribute

Methods

AddBlazorNativeDevice(IServiceCollection)

Registers IGeolocation, INotifications, IBiometrics, ISecureStorage and ICamera (the full M9 device roster — the 7th package is the last, no 8th). Requires an IMobileBridge to already be registered — each facade is a thin delegate over it.

// In your DI setup (the runtime composition root, or a test harness):
services.AddBlazorNativeDevice();

// In your component — inject the ergonomic facade, not the low-level bridge:
[Inject] public IGeolocation Geo { get; set; } = default!;
[Inject] public INotifications Notifications { get; set; } = default!;
[Inject] public IBiometrics Biometrics { get; set; } = default!;
[Inject] public ISecureStorage Secrets { get; set; } = default!;
[Inject] public ICamera Camera { get; set; } = default!;
public static IServiceCollection AddBlazorNativeDevice(IServiceCollection services)

Parameters

services IServiceCollection

Returns

IServiceCollection