コード例 #1
0
        public App(string pushNotifParam = null)
        {
            PushNotifParameter = pushNotifParam;
            currentApp         = this;
            InitializeComponent();

            // Load the FileAcces for secure Data Storage
            FileManager = DependencyService.Get <IFileManager>();
            NotificationEventReceiver = DependencyService.Get <INotificationEventReceiver>();
            var passwordManager = DependencyService.Get <IPasswordManager>();
            // loads the password from the platform dependent key manager
            var password = passwordManager.GetPassword();

            if (password == null)
            {
                // the first time we have to create a new password and save it.
                password = Encrypter.CreatePassword();
                passwordManager.SavePassword(password);
            }
            // With the initialized Password we can create the Encrypter, which is needed for any ViewModels access to data.
            Encrypter         = new Encrypter(password);
            ViewModelSettings = new ViewModel.ViewModelSettings();

            // The Midata-Access is loging in right at the beginning so it is always available (until the Timeout)
            Midata = new MidataLogin();
            Midata.Login();
            //BodyWeight bw = new BodyWeight("85", DateTime.Now);
            //midataAccess.SaveWeight(bw);

            // Main Navigation for the whole app which works with a NavigationStack.
            if (ViewModelSettings.newSettings)
            {
                if (PushNotifParameter == null)
                {
                    ((NavigationPage)MainPage).PushAsync(new View.Settings());
                }
            }
        }