| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | using System;using System.Diagnostics;using System.IO;using System.Threading;using System.Threading.Tasks;using Foundation;using InABox.Mobile;using InABox.Mobile.iOS;using Plugin.LocalNotification.Platforms;using UIKit;using UserNotifications;using Xamarin.Forms;using Syncfusion.TreeView;using Syncfusion.XForms.iOS.TreeView;using Syncfusion.XForms.iOS.PopupLayout;using Syncfusion.XForms.Pickers.iOS;namespace comal.timesheets.iOS{    // The UIApplicationDelegate for the application. This class is responsible for launching the     // User Interface of the application, as well as listening (and optionally responding) to     // application events from iOS.    [Register("AppDelegate")]    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate    {        //        // This method is invoked when the application has loaded and is ready to run. In this         // method you should instantiate the window, load the UI into it and then make the window        // visible.        //        // You have 17 seconds to return from this method, or iOS will terminate your application.        //        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)        {            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;            TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;                        DependencyService.Register<Version_iOS>();            global::Xamarin.Forms.Forms.Init();            Syncfusion.XForms.iOS.PopupLayout.SfPopupLayoutRenderer.Init();            Syncfusion.SfPdfViewer.XForms.iOS.SfPdfDocumentViewRenderer.Init();            Syncfusion.SfRangeSlider.XForms.iOS.SfRangeSliderRenderer.Init();            Syncfusion.SfImageEditor.XForms.iOS.SfImageEditorRenderer.Init();            Syncfusion.SfDataGrid.XForms.iOS.SfDataGridRenderer.Init();            Syncfusion.XForms.iOS.RichTextEditor.SfRichTextEditorRenderer.Init();            Syncfusion.SfMaps.XForms.iOS.SfMapsRenderer.Init();            Syncfusion.XForms.iOS.MaskedEdit.SfMaskedEditRenderer.Init();            SfTreeViewRenderer.Init();            Syncfusion.SfSchedule.XForms.iOS.SfScheduleRenderer.Init();            new Syncfusion.SfSchedule.XForms.iOS.SfScheduleRenderer();            XF.Material.iOS.Material.Init();            ZXing.Net.Mobile.Forms.iOS.Platform.Init();            Xamarin.IQKeyboardManager.SharedManager.Enable = true;            Syncfusion.XForms.iOS.SignaturePad.SfSignaturePadRenderer.Init();            Syncfusion.XForms.iOS.TabView.SfTabViewRenderer.Init();            SfTimePickerRenderer.Init();            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))            {                // Request notification permissions from the user                UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert, (approved, err) =>                {                    // Handle approval                });            }            UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))            {                var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null                );                uiApplication.RegisterUserNotificationSettings(notificationSettings);            }            // check for a notification            if (launchOptions != null)            {                // check for a local notification                if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))                {                    var localNotification =                        launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;                    if (localNotification != null)                    {                        UIAlertController okayAlertController = UIAlertController.Create(localNotification.AlertAction,                            localNotification.AlertBody, UIAlertControllerStyle.Alert);                        okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));                        Window.RootViewController.PresentViewController(okayAlertController, true, null);                        // reset our badge                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;                    }                }            }            LoadApplication(new App());            return base.FinishedLaunching(uiApplication, launchOptions);        }        public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)        {            // show an alert            UIAlertController okayAlertController = UIAlertController.Create(notification.AlertAction,                notification.AlertBody, UIAlertControllerStyle.Alert);            okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(okayAlertController,                true, null);            // reset our badge            UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;        }        public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)        {                        App.LaunchParameters = url.AbsoluteString.Remove(0, 17);            LoadApplication(new App());            return true;        }                #region Error handling        private static void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs args)        {            LogUnhandledException("TaskScheduler", args.Exception?.GetType(), args.Exception);        }        private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs args)        {            LogUnhandledException("CurrentDomain", args.ExceptionObject?.GetType(), args.ExceptionObject);        }        private static void LogUnhandledException(String source, Type type, object exceptionobject)        {            if (exceptionobject is Exception exception)                MobileLogging.Log(exception, source);            else                MobileLogging.Log($"{source}: {type?.Name ?? "NULL"} -> {exceptionobject}");        }        #endregion    }}
 |