-
-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathShinyExtensions.cs
43 lines (38 loc) · 1.73 KB
/
ShinyExtensions.cs
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
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.LifecycleEvents;
using Shiny.Hosting;
using Shiny.Infrastructure;
namespace Shiny;
public static class ShinyExtensions
{
public static MauiAppBuilder UseShiny(this MauiAppBuilder builder)
{
builder.Services.AddSingleton<IMauiInitializeService, ShinyMauiInitializationService>();
builder.Services.AddShinyCoreServices();
builder.ConfigureLifecycleEvents(events =>
{
#if ANDROID
events.AddAndroid(android => android
// Shiny will supply app foreground/background events
.OnCreate((activity, savedInstanceState) => Host.Lifecycle.OnActivityOnCreate(activity, savedInstanceState))
.OnRequestPermissionsResult((activity, requestCode, permissions, grantResults) => Host.Lifecycle.OnRequestPermissionsResult(activity, requestCode, permissions, grantResults))
.OnActivityResult((activity, requestCode, result, intent) => Host.Lifecycle.OnActivityResult(activity, requestCode, result, intent))
.OnNewIntent((activity, intent) => Host.Lifecycle.OnNewIntent(activity, intent))
);
#elif APPLE
// Shiny will supply push events & handle background url for http transfers
events.AddiOS(ios => ios
.ContinueUserActivity((_, activity, handler) => Host.Lifecycle.OnContinueUserActivity(activity, handler))
);
#elif WINDOWS
events.AddWindows(win => win
.OnLaunching((app, args) => { })
.OnClosed((app, args) => { })
.OnVisibilityChanged((app, args) => { })
);
#endif
});
return builder;
}
}