public void InitApp() { if (ServiceContainer.RegisteredServices.Count > 0) { return; } // Migration services ServiceContainer.Register <ILogService>("logService", new ConsoleLogService()); // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false }); }); iOSCoreHelpers.RegisterLocalServices(); RegisterPush(); var deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); ServiceContainer.Init(deviceActionService.DeviceUserAgent); _pushHandler = new iOSPushNotificationHandler( ServiceContainer.Resolve <IPushNotificationListenerService>("pushNotificationListenerService")); _nfcDelegate = new NFCReaderDelegate((success, message) => _messagingService.Send("gotYubiKeyOTP", message)); iOSCoreHelpers.Bootstrap(async() => await ApplyManagedSettingsAsync()); }
public void InitApp() { if (ServiceContainer.RegisteredServices.Count > 0) { return; } // Migration services ServiceContainer.Register <ILogService>("logService", new ConsoleLogService()); ServiceContainer.Register("settingsShim", new App.Migration.SettingsShim(iOSCoreHelpers.AppGroupId)); if (App.Migration.MigrationHelpers.NeedsMigration()) { ServiceContainer.Register <App.Migration.Abstractions.IOldSecureStorageService>( "oldSecureStorageService", new Migration.KeyChainStorageService()); } // Note: This might cause a race condition. Investigate more. Task.Run(() => { FFImageLoading.Forms.Platform.CachedImageRenderer.Init(); FFImageLoading.ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration { FadeAnimationEnabled = false, FadeAnimationForCachedImages = false }); }); iOSCoreHelpers.RegisterLocalServices(); RegisterPush(); ServiceContainer.Init(); iOSCoreHelpers.RegisterHockeyApp(); _pushHandler = new iOSPushNotificationHandler( ServiceContainer.Resolve <IPushNotificationListenerService>("pushNotificationListenerService")); _nfcDelegate = new NFCReaderDelegate((success, message) => _messagingService.Send("gotYubiKeyOTP", message)); iOSCoreHelpers.Bootstrap(); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Forms.Init(); if (!Resolver.IsSet) { SetIoc(); } _lockService = Resolver.Resolve <ILockService>(); _deviceInfoService = Resolver.Resolve <IDeviceInfoService>(); _pushHandler = new iOSPushNotificationHandler(Resolver.Resolve <IPushNotificationListener>()); _nfcDelegate = new NFCReaderDelegate((success, message) => ProcessYubikey(success, message)); var appIdService = Resolver.Resolve <IAppIdService>(); var crashManagerDelegate = new HockeyAppCrashManagerDelegate( appIdService, Resolver.Resolve <IAuthService>()); var manager = BITHockeyManager.SharedHockeyManager; manager.Configure("51f96ae568ba45f699a18ad9f63046c3", crashManagerDelegate); manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend; manager.UserId = appIdService.AppId; manager.StartManager(); manager.Authenticator.AuthenticateInstallation(); manager.DisableMetricsManager = manager.DisableFeedbackManager = manager.DisableUpdateManager = true; LoadApplication(new App.App( null, Resolver.Resolve <IAuthService>(), Resolver.Resolve <IConnectivity>(), Resolver.Resolve <IDatabaseService>(), Resolver.Resolve <ISyncService>(), Resolver.Resolve <ISettings>(), _lockService, Resolver.Resolve <ILocalizeService>(), Resolver.Resolve <IAppInfoService>(), Resolver.Resolve <IAppSettingsService>(), Resolver.Resolve <IDeviceActionService>())); // Appearance stuff var primaryColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f); var grayLight = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); UINavigationBar.Appearance.ShadowImage = new UIImage(); UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); UIBarButtonItem.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor; UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).SetTitleColor(primaryColor, UIControlState.Normal); UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor; UIStepper.Appearance.TintColor = grayLight; UISlider.Appearance.TintColor = primaryColor; MessagingCenter.Subscribe <Xamarin.Forms.Application, ToolsExtensionPage>( Xamarin.Forms.Application.Current, "ShowAppExtension", (sender, page) => { var itemProvider = new NSItemProvider(new NSDictionary(), Core.Constants.UTTypeAppExtensionSetup); var extensionItem = new NSExtensionItem(); extensionItem.Attachments = new NSItemProvider[] { itemProvider }; var activityViewController = new UIActivityViewController(new NSExtensionItem[] { extensionItem }, null); activityViewController.CompletionHandler = (activityType, completed) => { page.EnabledExtension(completed && activityType == "com.8bit.bitwarden.find-login-action-extension"); }; var modal = UIApplication.SharedApplication.KeyWindow.RootViewController.ModalViewController; if (activityViewController.PopoverPresentationController != null) { activityViewController.PopoverPresentationController.SourceView = modal.View; var frame = UIScreen.MainScreen.Bounds; frame.Height /= 2; activityViewController.PopoverPresentationController.SourceRect = frame; } modal.PresentViewController(activityViewController, true, null); }); MessagingCenter.Subscribe <Xamarin.Forms.Application, bool>(Xamarin.Forms.Application.Current, "ListenYubiKeyOTP", (sender, listen) => { if (_deviceInfoService.NfcEnabled) { _nfcSession?.InvalidateSession(); _nfcSession?.Dispose(); _nfcSession = null; if (listen) { _nfcSession = new NFCNdefReaderSession(_nfcDelegate, null, true); _nfcSession.AlertMessage = AppResources.HoldYubikeyNearTop; _nfcSession.BeginSession(); } } }); UIApplication.SharedApplication.StatusBarHidden = false; UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent; MessagingCenter.Subscribe <Xamarin.Forms.Application, bool>(Xamarin.Forms.Application.Current, "ShowStatusBar", (sender, show) => { UIApplication.SharedApplication.SetStatusBarHidden(!show, false); }); ZXing.Net.Mobile.Forms.iOS.Platform.Init(); return(base.FinishedLaunching(app, options)); }