コード例 #1
0
ファイル: AppDelegate.cs プロジェクト: vbassini/CodeHub
        private void InitializeApp(NSDictionary options)
        {
            // Stamp the date this was installed (first run)
            var installedDate = this.StampInstallDate("CodeHub", DateTime.Now.ToString());
            if (installedDate < new DateTime(2015, 12, 5))
                IsPro = true;

            // Register default settings from the settings.bundle
            RegisterDefaultSettings();

            Locator.CurrentMutable.InitializeFactories();
            Locator.CurrentMutable.InitializeServices();
            Bootstrap.Init();

            // Enable flurry analytics
            if (ObjCRuntime.Runtime.Arch != ObjCRuntime.Arch.SIMULATOR)
            {
                Flurry.Analytics.FlurryAgent.SetCrashReportingEnabled(true);
                Flurry.Analytics.FlurryAgent.StartSession("FXD7V6BGG5KHWZN3FFBX");
            }
            else
            {
                this.Log().Debug("Simulator detected, disabling analytics");
                Locator.Current.GetService<IAnalyticsService>().Enabled = false;
            }

            _settingsChangedObserver = NSNotificationCenter.DefaultCenter.AddObserver((NSString)"NSUserDefaultsDidChangeNotification", DefaultsChanged); 

            System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

            OctokitClientFactory.CreateMessageHandler = () => new HttpMessageHandler();
            GitHubSharp.Client.ClientConstructor = () => new HttpClient(new HttpMessageHandler());

            var viewModelViews = Locator.Current.GetService<IViewModelViewService>();
            var defaultValueService = Locator.Current.GetService<IDefaultValueService>();
            viewModelViews.RegisterViewModels(typeof(SettingsViewController).Assembly);

            Themes.Theme.Load("Default");

            try
            {
                Data.LegacyMigration.Migrate(Locator.Current.GetService<IAccountsRepository>());
            }
            catch (Exception e)
            {
                this.Log().DebugException("Unable to migrate db!", e);
            }

            bool hasSeenWelcome;
            if (!defaultValueService.TryGet("HAS_SEEN_WELCOME_INTRO", out hasSeenWelcome) || !hasSeenWelcome)
            {
                defaultValueService.Set("HAS_SEEN_WELCOME_INTRO", true);
                var welcomeViewController = new WelcomePageViewController();
                welcomeViewController.WantsToDimiss += GoToStartupView;
                TransitionToViewController(welcomeViewController);
            }
            else
            {
                GoToStartupView();
            }

            SetupPushNotifications();
            HandleNotificationOptions(options);
        }
コード例 #2
0
ファイル: AppDelegate.cs プロジェクト: xiaochen254/CodeHub
        /// <summary>
        /// Finished the launching.
        /// </summary>
        /// <param name="app">The app.</param>
        /// <param name="options">The options.</param>
        /// <returns>True or false.</returns>
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Crashlytics.Instance.Initialize();
            Fabric.Instance.Initialize();

#if DEBUG
            Fabric.Instance.Debug = true;
#endif

            Window    = new UIWindow(UIScreen.MainScreen.Bounds);
            Presenter = new IosViewPresenter(this.Window);
            var setup = new Setup(this, Presenter);
            setup.Initialize();

            var culture = new System.Globalization.CultureInfo("en");
            System.Threading.Thread.CurrentThread.CurrentCulture           = culture;
            System.Threading.Thread.CurrentThread.CurrentUICulture         = culture;
            System.Globalization.CultureInfo.DefaultThreadCurrentCulture   = culture;
            System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = culture;

            // Setup theme
            UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, true);
            Theme.Setup();

            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <IApplicationService>());
            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <IAccountsService>());
            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <IAlertDialogService>());
            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <INetworkActivityService>());
            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <IMessageService>());
            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <IInAppPurchaseService>());
            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <IFeaturesService>());
            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <ILoginService>());
            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <IMarkdownService>());
            Locator.CurrentMutable.RegisterConstant(Mvx.Resolve <IPushNotificationsService>());

            Locator.CurrentMutable.RegisterLazySingleton(
                () => new ImgurService(), typeof(IImgurService));

            var features        = Mvx.Resolve <IFeaturesService>();
            var purchaseService = Mvx.Resolve <IInAppPurchaseService>();

            purchaseService.ThrownExceptions.Subscribe(ex =>
            {
                var error = new Core.UserError("Error Purchasing", ex.Message);
                Core.Interactions.Errors.Handle(error).Subscribe();
            });

            Core.Interactions.Errors.RegisterHandler(interaction =>
            {
                var error = interaction.Input;
                AlertDialogService.ShowAlert(error.Title, error.Message);
                interaction.SetOutput(System.Reactive.Unit.Default);
            });

#if DEBUG
            features.ActivateProDirect();
#endif

            //options = new NSDictionary (UIApplication.LaunchOptionsRemoteNotificationKey,
            //new NSDictionary ("r", "octokit/octokit.net", "i", "739", "u", "thedillonb"));

            if (options != null)
            {
                if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    var remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                    if (remoteNotification != null)
                    {
                        HandleNotification(remoteNotification, true);
                    }
                }
            }

            // Set the client constructor
            GitHubSharp.Client.ClientConstructor = () => new HttpClient(new CustomHttpMessageHandler());

            if (!Core.Settings.HasSeenWelcome)
            {
                Core.Settings.HasSeenWelcome = true;
                var welcomeViewController = new ViewControllers.Walkthrough.WelcomePageViewController();
                welcomeViewController.WantsToDimiss += GoToStartupView;
                TransitionToViewController(welcomeViewController);
            }
            else
            {
                GoToStartupView();
            }

            Window.MakeKeyAndVisible();

            // Notifications don't work on teh simulator so don't bother
            if (Runtime.Arch != Arch.SIMULATOR && features.IsProEnabled)
            {
                RegisterUserForNotifications();
            }

            return(true);
        }
コード例 #3
0
ファイル: AppDelegate.cs プロジェクト: crazypebble/CodeHub
        private void InitializeApp(NSDictionary options)
        {
            // Stamp the date this was installed (first run)
            var installedDate = this.StampInstallDate("CodeHub", DateTime.Now.ToString());
            if (installedDate < new DateTime(2015, 12, 5))
                IsPro = true;

            // Register default settings from the settings.bundle
            RegisterDefaultSettings();

            Locator.CurrentMutable.InitializeFactories();
            Locator.CurrentMutable.InitializeServices();
            Bootstrap.Init();

            _settingsChangedObserver = NSNotificationCenter.DefaultCenter.AddObserver((NSString)"NSUserDefaultsDidChangeNotification", DefaultsChanged); 

            System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

            OctokitClientFactory.CreateMessageHandler = () => new System.Net.Http.HttpClientHandler();
            GitHubSharp.Client.ClientConstructor = () => new HttpClient(new HttpMessageHandler());

            var viewModelViews = Locator.Current.GetService<IViewModelViewService>();
            var defaultValueService = Locator.Current.GetService<IDefaultValueService>();
            viewModelViews.RegisterViewModels(typeof(SettingsViewController).Assembly);

            Theme.Setup();
            Theme.SetPrimary(null);
//
//            Locator.Current.GetService<ISessionService>().AccountObservable.Subscribe(x => {
//            });

//            try
//            {
//                Data.LegacyMigration.Migrate(Locator.Current.GetService<IAccountsRepository>());
//            }
//            catch (Exception e)
//            {
//                this.Log().DebugException("Unable to migrate db!", e);
//            }

            bool hasSeenWelcome;
            if (!defaultValueService.TryGet("HAS_SEEN_WELCOME_INTRO", out hasSeenWelcome) || !hasSeenWelcome)
            {
                defaultValueService.Set("HAS_SEEN_WELCOME_INTRO", true);
                var welcomeViewController = new WelcomePageViewController();
                welcomeViewController.WantsToDimiss += GoToStartupView;
                TransitionToViewController(welcomeViewController);
            }
            else
            {
                GoToStartupView();
            }

            SetupPushNotifications();
            HandleNotificationOptions(options);
        }