Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/BlazorWebView/src/Maui/BlazorWebView.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,8 +11,24 @@ namespace Microsoft.AspNetCore.Components.WebView.Maui
/// <summary>
/// A <see cref="View"/> that can render Blazor content.
/// </summary>
#if ANDROID
[SupportedOSPlatform(AndroidSupportedOSPlatformVersion)]
#elif IOS
[SupportedOSPlatform(iOSSupportedOSPlatformVersion)]
#elif MACCATALYST
[SupportedOSPlatform(MacCatalystSupportedOSPlatformVersion)]
#endif
Comment thread
jonathanpeppers marked this conversation as resolved.
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();
Expand Down Expand Up @@ -80,9 +97,11 @@ public string StartPath

/// <inheritdoc />
#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)
{
Expand All @@ -97,7 +116,11 @@ public virtual IFileProvider CreateFileProvider(string contentRootDir)
/// <returns>Returns a <see cref="Task"/> representing <c>true</c> if the <paramref name="workItem"/> was called, or <c>false</c> if it was not called because Blazor is not currently running.</returns>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="workItem"/> is <c>null</c>.</exception>
#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<bool> TryDispatchAsync(Action<IServiceProvider> workItem)
{
Expand Down
6 changes: 5 additions & 1 deletion src/BlazorWebView/src/Maui/BlazorWebViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
namespace Microsoft.AspNetCore.Components.WebView.Maui
{
#if ANDROID
[SupportedOSPlatform("android23.0")]
[SupportedOSPlatform(BlazorWebView.AndroidSupportedOSPlatformVersion)]
#elif IOS
[SupportedOSPlatform(BlazorWebView.iOSSupportedOSPlatformVersion)]
Comment thread
jonathanpeppers marked this conversation as resolved.
#elif MACCATALYST
[SupportedOSPlatform(BlazorWebView.MacCatalystSupportedOSPlatformVersion)]
#endif
public partial class BlazorWebViewHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<PackageTags>$(DefaultPackageTags);blazor;webview;aspnet</PackageTags>
<PackageIconFullPath>$(MauiRootDirectory)Assets\aspnet-icon.png</PackageIconFullPath>
<Description>Build .NET Multi-platform App UI (.NET MAUI) apps with Blazor web UI in the BlazorWebView control.</Description>
<!-- NOTE: keep in sync with BlazorWebView.cs -->
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">24.0</SupportedOSPlatformVersion>
Comment thread
jonathanpeppers marked this conversation as resolved.
</PropertyGroup>

<Import Project="$(MauiSrcDirectory)MultiTargeting.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Comment thread
jonathanpeppers marked this conversation as resolved.
#elif MACCATALYST
[System.Runtime.Versioning.SupportedOSPlatform(BlazorWebView.MacCatalystSupportedOSPlatformVersion)]
#endif
public static IMauiBlazorWebViewBuilder AddMauiBlazorWebView(this IServiceCollection services)
#else
Expand Down
Loading