Esempio n. 1
0
        internal static MauiAppBuilder UseEssentials(this MauiAppBuilder builder)
        {
            builder.ConfigureLifecycleEvents(life =>
            {
#if __ANDROID__
                Platform.Init(MauiApplication.Current);

                life.AddAndroid(android => android
                                .OnCreate((activity, savedInstanceState) =>
                {
                    Platform.Init(activity, savedInstanceState);
                })
                                .OnRequestPermissionsResult((activity, requestCode, permissions, grantResults) =>
                {
                    Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
                })
                                .OnNewIntent((activity, intent) =>
                {
                    Platform.OnNewIntent(intent);
                })
                                .OnResume((activity) =>
                {
                    Platform.OnResume();
                }));
#elif __IOS__
                life.AddiOS(ios => ios
                            .ContinueUserActivity((application, userActivity, completionHandler) =>
                {
                    return(Platform.ContinueUserActivity(application, userActivity, completionHandler));
                })
                            .OpenUrl((application, url, options) =>
                {
                    return(Platform.OpenUrl(application, url, options));
                })
                            .PerformActionForShortcutItem((application, shortcutItem, completionHandler) =>
                {
                    Platform.PerformActionForShortcutItem(application, shortcutItem, completionHandler);
                }));
#elif WINDOWS
                life.AddWindows(windows => windows
                                .OnNativeMessage((window, args) =>
                {
                    Platform.NewWindowProc(args.Hwnd, args.MessageId, args.WParam, args.LParam);
                })
                                .OnActivated((window, args) =>
                {
                    Platform.OnActivated(window, args);
                })
                                .OnLaunched((application, args) =>
                {
                    Platform.OnLaunched(args);
                }));
#endif
            });

            return(builder);
        }