Exemple #1
0
        public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
        {
            // TODO: add your long-running task here
            // DB init - to fix
            if (firstInit)
            {
                firstInit = false;
                using (var db = new LocalContext())
                {
                    try
                    {
                        db.Database.Migrate();
                    }
                    catch (Exception)
                    {
                        // first time exception
                    }
                    await db.InitMigrateAsync();
                }
                Init();
            }

            // Get Device Type
            SettingsService.Instance.DeviceType = DeviceTypeHelper.GetDeviceFormFactorType();

            // Check for connection
            SettingsService.Instance.CheckConnections();

            Views.Shell.HamburgerMenu.IsFullScreen = true;

            if (args.Kind == ActivationKind.Protocol)
            {
                var protocolUri = (args as ProtocolActivatedEventArgs).Uri;
                var token       = await DataUtils.TryGetToken(protocolUri);

                if (!string.IsNullOrWhiteSpace(token))
                {
                    await PassportService.Instance.GetProfileData(token);
                }
            }
            if (SettingsService.Instance.CurrentUserData?.CanUse() ?? false)
            {
                Views.Shell.HamburgerMenu.IsFullScreen = false;
                await NavigationService.NavigateAsync(typeof(Views.MainPage));
            }
            else
            {
                await NavigationService.NavigateAsync(typeof(Views.LoginPage));
            }
        }