Esempio n. 1
0
 public override void OnCreate()
 {
     base.OnCreate();
     EarlyIoC.Register();
     RegisterActivityLifecycleCallbacks(this);
     //A great place to initialize Xamarin.Insights and Dependency Services!
 }
Esempio n. 2
0
        //
        // 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 app, NSDictionary options)
        {
            EarlyIoC.Register();

            var dataAccess = IoCManager.Resolve <IDataAccess>();

            if (Settings.ShouldDeleteDbOnLaunch)
            {
                File.Delete(dataAccess.DatabasePath);
                Settings.ShouldDeleteDbOnLaunch = false;
            }

            dataAccess.CreateDatabase(0); // ensures the database exists and is up to date

            IoCManager.RegisterType <IImageDimension, IosImageDimensions>();
            IoCManager.RegisterType <IAppCloser, IosAppCloser>();

            // Init Navigation
            NavigationService.Instance.RegisterViewModels(typeof(MainPage).Assembly);
            IoCManager.RegisterInstance(typeof(INavigationService), NavigationService.Instance);
            IoCManager.RegisterInstance(typeof(IViewCreator), NavigationService.Instance);

            // init other inversion of control classes
            IoCManager.RegisterType <IAudioPlayer, IosAudioPlayer>();
            IoCManager.RegisterInstance(typeof(INotificationPlayer), new IosNotificationPlayer());
            IoCManager.RegisterInstance(typeof(ILocationManager), new LocationManager());
            IoCManager.RegisterInstance(typeof(IKeyProvider), new IosKeyProvider());
            IoCManager.RegisterInstance(typeof(IBarsColorsChanger), new IosBarsColorsChanger());
            IoCManager.RegisterInstance(typeof(IDbChangedHandler), new DbChangedHandler());
            IoCManager.RegisterInstance(typeof(INetworkAccessChecker), new IosNetworkAccessChecker());
            IoCManager.RegisterInstance(typeof(IStorageSizeProvider), new IosStorageSizeProvider());

            // init crash manager
            var manager = BITHockeyManager.SharedHockeyManager;

            manager.Configure(IoCManager.Resolve <IKeyProvider>().GetKeyByName("hockeyapp.ios"));
            manager.DisableUpdateManager = true;
            manager.StartManager();
            manager.Authenticator.AuthenticateInstallation();

            // init forms and third party libraries
            CachedImageRenderer.Init();
            Xamarin.Forms.Forms.Init();
            CarouselViewRenderer.Init();

            DesignMode.IsEnabled = false;
            LoadApplication(new App());

#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif

            // display dialogue to ask for users permission to display notifications
            UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert, (approved, err) =>
            {
                // You could evaluate approval and error here
            });

            return(base.FinishedLaunching(app, options));
        }