diff --git a/src/BlazorWebView/src/Maui/BlazorWebView.cs b/src/BlazorWebView/src/Maui/BlazorWebView.cs index 15922e86b364..d54ee207cf77 100644 --- a/src/BlazorWebView/src/Maui/BlazorWebView.cs +++ b/src/BlazorWebView/src/Maui/BlazorWebView.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using System.Runtime.Versioning; using Microsoft.AspNetCore.Components.Web; using Microsoft.Extensions.FileProviders; using Microsoft.Maui; @@ -10,8 +11,24 @@ namespace Microsoft.AspNetCore.Components.WebView.Maui /// /// A that can render Blazor content. /// +#if ANDROID + [SupportedOSPlatform(AndroidSupportedOSPlatformVersion)] +#elif IOS + [SupportedOSPlatform(iOSSupportedOSPlatformVersion)] +#elif MACCATALYST + [SupportedOSPlatform(MacCatalystSupportedOSPlatformVersion)] +#endif public partial class BlazorWebView : View, IBlazorWebView { + // NOTE: keep these in *reasonably* in sync with: + // * src\BlazorWebView\src\Maui\Microsoft.AspNetCore.Components.WebView.Maui.csproj + // * src\Templates\src\templates\maui-blazor\MauiApp.1.csproj + // * src\Templates\src\templates\maui-blazor-solution\MauiApp.1\MauiApp.1.csproj + // * https://learn.microsoft.com/dotnet/maui/supported-platforms + internal const string AndroidSupportedOSPlatformVersion = "android24.0"; + internal const string iOSSupportedOSPlatformVersion = "ios15.0"; + internal const string MacCatalystSupportedOSPlatformVersion = "maccatalyst15.0"; + internal static string AppHostAddress { get; } = HostAddressHelper.GetAppHostAddress(); private readonly JSComponentConfigurationStore _jSComponents = new(); @@ -80,9 +97,11 @@ public string StartPath /// #if ANDROID - [System.Runtime.Versioning.SupportedOSPlatform("android23.0")] + [System.Runtime.Versioning.SupportedOSPlatform(AndroidSupportedOSPlatformVersion)] #elif IOS - [System.Runtime.Versioning.SupportedOSPlatform("ios11.0")] + [System.Runtime.Versioning.SupportedOSPlatform(iOSSupportedOSPlatformVersion)] +#elif MACCATALYST + [System.Runtime.Versioning.SupportedOSPlatform(MacCatalystSupportedOSPlatformVersion)] #endif public virtual IFileProvider CreateFileProvider(string contentRootDir) { @@ -97,7 +116,11 @@ public virtual IFileProvider CreateFileProvider(string contentRootDir) /// Returns a representing true if the was called, or false if it was not called because Blazor is not currently running. /// Thrown if is null. #if ANDROID - [System.Runtime.Versioning.SupportedOSPlatform("android23.0")] + [System.Runtime.Versioning.SupportedOSPlatform(AndroidSupportedOSPlatformVersion)] +#elif IOS + [System.Runtime.Versioning.SupportedOSPlatform(iOSSupportedOSPlatformVersion)] +#elif MACCATALYST + [System.Runtime.Versioning.SupportedOSPlatform(MacCatalystSupportedOSPlatformVersion)] #endif public virtual async Task TryDispatchAsync(Action workItem) { diff --git a/src/BlazorWebView/src/Maui/BlazorWebViewHandler.cs b/src/BlazorWebView/src/Maui/BlazorWebViewHandler.cs index 052a96f5586f..df638d6d7cd1 100644 --- a/src/BlazorWebView/src/Maui/BlazorWebViewHandler.cs +++ b/src/BlazorWebView/src/Maui/BlazorWebViewHandler.cs @@ -9,7 +9,11 @@ namespace Microsoft.AspNetCore.Components.WebView.Maui { #if ANDROID - [SupportedOSPlatform("android23.0")] + [SupportedOSPlatform(BlazorWebView.AndroidSupportedOSPlatformVersion)] +#elif IOS + [SupportedOSPlatform(BlazorWebView.iOSSupportedOSPlatformVersion)] +#elif MACCATALYST + [SupportedOSPlatform(BlazorWebView.MacCatalystSupportedOSPlatformVersion)] #endif public partial class BlazorWebViewHandler { diff --git a/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj b/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj index d4268f64fa8f..115ba0586b46 100644 --- a/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj +++ b/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj @@ -23,6 +23,10 @@ $(DefaultPackageTags);blazor;webview;aspnet $(MauiRootDirectory)Assets\aspnet-icon.png Build .NET Multi-platform App UI (.NET MAUI) apps with Blazor web UI in the BlazorWebView control. + + 15.0 + 15.0 + 24.0 diff --git a/src/BlazorWebView/src/SharedSource/BlazorWebViewServiceCollectionExtensions.cs b/src/BlazorWebView/src/SharedSource/BlazorWebViewServiceCollectionExtensions.cs index b7b0c748177d..a83a5e187c3c 100644 --- a/src/BlazorWebView/src/SharedSource/BlazorWebViewServiceCollectionExtensions.cs +++ b/src/BlazorWebView/src/SharedSource/BlazorWebViewServiceCollectionExtensions.cs @@ -30,9 +30,11 @@ public static IWindowsFormsBlazorWebViewBuilder AddWindowsFormsBlazorWebView(thi public static IWpfBlazorWebViewBuilder AddWpfBlazorWebView(this IServiceCollection services) #elif WEBVIEW2_MAUI #if ANDROID - [System.Runtime.Versioning.SupportedOSPlatform("android23.0")] + [System.Runtime.Versioning.SupportedOSPlatform(BlazorWebView.AndroidSupportedOSPlatformVersion)] #elif IOS - [System.Runtime.Versioning.SupportedOSPlatform("ios11.0")] + [System.Runtime.Versioning.SupportedOSPlatform(BlazorWebView.iOSSupportedOSPlatformVersion)] +#elif MACCATALYST + [System.Runtime.Versioning.SupportedOSPlatform(BlazorWebView.MacCatalystSupportedOSPlatformVersion)] #endif public static IMauiBlazorWebViewBuilder AddMauiBlazorWebView(this IServiceCollection services) #else