-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathMauiProgram.cs
More file actions
50 lines (44 loc) · 1.4 KB
/
MauiProgram.cs
File metadata and controls
50 lines (44 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Microsoft.Extensions.Logging;
#if IOS || MACCATALYST
using WebKit;
#endif
namespace dnet_maui_blazor_hybrid
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
builder.Services.AddMauiBlazorWebView();
#if IOS || MACCATALYST
Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.BlazorWebViewMapper.Add("AllowCameraPermission", (handler, view) =>
{
handler.PlatformView.UIDelegate = new AllowCameraPermissionWebViewDelegate();
});
#endif
#if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools();
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
#if IOS || MACCATALYST
public class AllowCameraPermissionWebViewDelegate : WKUIDelegate
{
public override void RequestMediaCapturePermission(
WKWebView webView,
WKSecurityOrigin origin,
WKFrameInfo frame,
WKMediaCaptureType type,
Action<WKPermissionDecision> decisionHandler
) => decisionHandler(WKPermissionDecision.Grant);
}
#endif
}