Skip to content
Shiny .NET v4 is here with BLE Windows Support, Improved GPS, & More! Check It Out

Manual Hosting

Manual hosting gives you full control when you can’t inherit from Shiny’s base classes — for example, when your app already has custom Application, AppDelegate, or Activity classes that you can’t change.

You call Host.Lifecycle methods directly from your existing platform code to hook Shiny into the native lifecycle.

  1. Install the NuGet package

    NuGet package Shiny.Core
  2. Build the host at app startup

    Create and run the Shiny host as early as possible in your app’s lifecycle.

    using Foundation;
    using UIKit;
    using Shiny.Hosting;
    namespace YourNamespace;
    public class AppDelegate : UIApplicationDelegate
    {
    public override bool FinishedLaunching(
    UIApplication application,
    NSDictionary launchOptions)
    {
    var host = HostBuilder.Create();
    // Register your Shiny modules and services here
    host.Build().Run();
    return base.FinishedLaunching(application, launchOptions);
    }
    }
  3. Wire up lifecycle callbacks

    Forward platform events to Host.Lifecycle from your existing classes.

    Add these to your AppDelegate:

    // Required for HTTP Transfers
    public override void HandleEventsForBackgroundUrl(
    UIApplication application,
    string sessionIdentifier,
    Action completionHandler)
    {
    Host.Lifecycle.OnHandleEventsForBackgroundUrl(
    sessionIdentifier, completionHandler);
    }
    // Required for Push Notifications
    public override void RegisteredForRemoteNotifications(
    UIApplication application, NSData deviceToken)
    {
    Host.Lifecycle.OnRegisteredForRemoteNotifications(deviceToken);
    }
    public override void FailedToRegisterForRemoteNotifications(
    UIApplication application, NSError error)
    {
    Host.Lifecycle.OnFailedToRegisterForRemoteNotifications(error);
    }
    public override void DidReceiveRemoteNotification(
    UIApplication application,
    NSDictionary userInfo,
    Action<UIBackgroundFetchResult> completionHandler)
    {
    Host.Lifecycle.OnDidReceiveRemoteNotification(
    userInfo, completionHandler);
    }
    // Required for deep links / universal links
    public override bool ContinueUserActivity(
    UIApplication application,
    NSUserActivity userActivity,
    UIApplicationRestorationHandler completionHandler)
    {
    Host.Lifecycle.OnContinueUserActivity(
    userActivity, completionHandler);
    return true;
    }

Mac Catalyst apps use the iOS tab above directly — the same UIApplicationDelegate callbacks apply.

Native macOS (AppKit) follows the same forwarding pattern but against NSApplicationDelegate. If you’re using Shiny.Push, wire these methods to Host.Lifecycle:

using AppKit;
using Foundation;
using ObjCRuntime;
using Shiny.Hosting;
public class AppDelegate : NSApplicationDelegate
{
[Export("application:didRegisterForRemoteNotificationsWithDeviceToken:")]
public void DidRegisterForRemoteNotifications(NSApplication app, NSData deviceToken)
=> Host.Lifecycle.OnRegisteredForRemoteNotifications(deviceToken);
[Export("application:didFailToRegisterForRemoteNotificationsWithError:")]
public void DidFailToRegisterForRemoteNotifications(NSApplication app, NSError error)
=> Host.Lifecycle.OnFailedToRegisterForRemoteNotifications(error);
[Export("application:didReceiveRemoteNotification:")]
public void DidReceiveRemoteNotification(NSApplication app, NSDictionary userInfo)
=> Host.Lifecycle.OnDidReceiveRemoteNotification(userInfo);
}

Shiny modules with native macOS support: BLE, BLE Hosting, Notifications, Push, Battery, Connectivity.

Nothing to forward on Linux — there’s no platform lifecycle. Register Shiny services directly on your service collection and you’re done.

Nothing extra is needed. Blazor has no native lifecycle callbacks to forward — register Shiny services directly on WebAssemblyHostBuilder.Services in your Blazor Program.cs.

MethodPlatformUsed By
OnActivityOnCreateAndroidAll modules
OnNewIntentAndroidNotifications, Push
OnActivityResultAndroidVarious
OnRequestPermissionsResultAndroidAll modules
OnHandleEventsForBackgroundUrliOSHTTP Transfers
OnRegisteredForRemoteNotificationsiOSPush
OnFailedToRegisterForRemoteNotificationsiOSPush
OnDidReceiveRemoteNotificationiOSPush
OnContinueUserActivityiOSDeep links