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{}