Native Hosting
For .NET native apps that don’t use MAUI, Shiny provides base classes that wire up all the platform lifecycle hooks automatically. You inherit from Shiny’s base classes and override a single method to configure your services.
-
Install the NuGet package
-
Create your platform entry points
Inherit from
ShinyAppDelegate:using Shiny;using Shiny.Hosting;using Foundation;using UIKit;namespace YourNamespace;public class MyDelegate : ShinyAppDelegate{protected override IHost CreateShinyHost(){var builder = HostBuilder.Create();// Register your Shiny modules and services herereturn builder.Build();}public override bool FinishedLaunching(UIApplication application,NSDictionary launchOptions){// Your launch code here — don't call Shiny before basereturn base.FinishedLaunching(application, launchOptions);}}You need both an Application and an Activity class.
Application — inherit from
ShinyAndroidApplication:using System;using Android.App;using Android.Runtime;using Shiny.Hosting;namespace YourNamespace;public class YourApplication : ShinyAndroidApplication{public YourApplication(IntPtr javaReference,JniHandleOwnership transfer): base(javaReference, transfer) {}protected override IHost CreateShinyHost(){var builder = HostBuilder.Create();// Register your Shiny modules and services herereturn builder.Build();}}Activity — inherit from
ShinyAndroidActivity:using Android.App;using Android.Content.PM;namespace YourNamespace;[Activity(Theme = "@style/YourTheme",MainLauncher = true,ConfigurationChanges =ConfigChanges.ScreenSize |ConfigChanges.Orientation |ConfigChanges.UiMode |ConfigChanges.ScreenLayout |ConfigChanges.SmallestScreenSize |ConfigChanges.Density)]public class MainActivity : ShinyAndroidActivity{}
Other Platforms
Section titled “Other Platforms”Mac Catalyst apps use the iOS / Mac Catalyst tab above — ShinyAppDelegate inherits from UIApplicationDelegate and works out of the box.
Native macOS (AppKit) has no Shiny base class to inherit from. Use the MAUI macOS backend with an NSApplicationDelegate that inherits from MacOSMauiApplication, register Shiny services directly on builder.Services, and forward the NSApplicationDelegate push callbacks to Host.Lifecycle if you’re using Shiny.Push. See the MAUI hosting → macOS (native) section for the full wire-up.
Shiny modules with native macOS support: BLE, BLE Hosting, Notifications, Push, Battery, Connectivity.
Linux has no hosting model at all — there are no OS-level lifecycle callbacks to wire. Register Shiny services directly on your IServiceCollection (whether that’s builder.Services on a MAUI GTK4 app or a plain ServiceCollection() in a console app). Nothing extra is needed.
Blazor WebAssembly
Section titled “Blazor WebAssembly”Nothing extra is needed. Blazor has no native lifecycle to wire up — register Shiny services directly on builder.Services in your Blazor Program.cs:
var builder = WebAssemblyHostBuilder.CreateDefault(args);builder.Services.AddBluetoothLE();builder.Services.AddGps();await builder.Build().RunAsync();