AppDelegate.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. 
  2. using Foundation;
  3. using InABox.Mobile.iOS;
  4. using Plugin.LocalNotification.Platforms;
  5. using UIKit;
  6. using UserNotifications;
  7. using Xamarin.Forms;
  8. using Syncfusion.TreeView;
  9. using Syncfusion.XForms.iOS.TreeView;
  10. using Syncfusion.XForms.iOS.PopupLayout;
  11. namespace comal.timesheets.iOS
  12. {
  13. // The UIApplicationDelegate for the application. This class is responsible for launching the
  14. // User Interface of the application, as well as listening (and optionally responding) to
  15. // application events from iOS.
  16. [Register("AppDelegate")]
  17. public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
  18. {
  19. //
  20. // This method is invoked when the application has loaded and is ready to run. In this
  21. // method you should instantiate the window, load the UI into it and then make the window
  22. // visible.
  23. //
  24. // You have 17 seconds to return from this method, or iOS will terminate your application.
  25. //
  26. public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
  27. {
  28. DependencyService.Register<Version_iOS>();
  29. global::Xamarin.Forms.Forms.Init();
  30. Syncfusion.XForms.iOS.PopupLayout.SfPopupLayoutRenderer.Init();
  31. Syncfusion.SfPdfViewer.XForms.iOS.SfPdfDocumentViewRenderer.Init();
  32. Syncfusion.SfRangeSlider.XForms.iOS.SfRangeSliderRenderer.Init();
  33. Syncfusion.SfImageEditor.XForms.iOS.SfImageEditorRenderer.Init();
  34. Syncfusion.SfDataGrid.XForms.iOS.SfDataGridRenderer.Init();
  35. Syncfusion.XForms.iOS.RichTextEditor.SfRichTextEditorRenderer.Init();
  36. Syncfusion.SfMaps.XForms.iOS.SfMapsRenderer.Init();
  37. Syncfusion.XForms.iOS.MaskedEdit.SfMaskedEditRenderer.Init();
  38. SfTreeViewRenderer.Init();
  39. Syncfusion.SfSchedule.XForms.iOS.SfScheduleRenderer.Init();
  40. XF.Material.iOS.Material.Init();
  41. ZXing.Net.Mobile.Forms.iOS.Platform.Init();
  42. Xamarin.IQKeyboardManager.SharedManager.Enable = true;
  43. Syncfusion.XForms.iOS.SignaturePad.SfSignaturePadRenderer.Init();
  44. if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
  45. {
  46. // Request notification permissions from the user
  47. UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert, (approved, err) =>
  48. {
  49. // Handle approval
  50. });
  51. }
  52. UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
  53. if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
  54. {
  55. var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
  56. UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
  57. );
  58. uiApplication.RegisterUserNotificationSettings(notificationSettings);
  59. }
  60. // check for a notification
  61. if (launchOptions != null)
  62. {
  63. // check for a local notification
  64. if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
  65. {
  66. var localNotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
  67. if (localNotification != null)
  68. {
  69. UIAlertController okayAlertController = UIAlertController.Create(localNotification.AlertAction, localNotification.AlertBody, UIAlertControllerStyle.Alert);
  70. okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
  71. Window.RootViewController.PresentViewController(okayAlertController, true, null);
  72. // reset our badge
  73. UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
  74. }
  75. }
  76. }
  77. LoadApplication(new App());
  78. return base.FinishedLaunching(uiApplication, launchOptions);
  79. }
  80. public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
  81. {
  82. // show an alert
  83. UIAlertController okayAlertController = UIAlertController.Create(notification.AlertAction, notification.AlertBody, UIAlertControllerStyle.Alert);
  84. okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
  85. UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(okayAlertController, true, null);
  86. // reset our badge
  87. UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
  88. }
  89. public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
  90. {
  91. GlobalVariables.LoadFromLinkString = url.AbsoluteString.Remove(0,17);
  92. LoadApplication(new App());
  93. return true;
  94. }
  95. }
  96. }