Esempio n. 1
0
        public async void OnNavigatedTo(INavigationParameters parameters)
        {
            var permissionStatus = await Permissions.CheckStatusAsync <Permissions.LocationWhenInUse>();

            while (!PermissionGranted(permissionStatus))
            {
                await _userDialogs.AlertAsync(new AlertConfig
                {
                    Message = "Oh no!, seems like we can't access your location. To continue please give this app the corresponding access",
                    OkText  = "Ok",
                    Title   = "Permission not granted",
                });

                await Permissions.RequestAsync <Permissions.LocationWhenInUse>();

                permissionStatus = await Permissions.CheckStatusAsync <Permissions.LocationWhenInUse>();
            }

            if (UserLocation == null)
            {
                var geolocation = await Geolocation.GetLastKnownLocationAsync();

                UserLocation = new Place
                {
                    Latitude  = geolocation.Latitude,
                    Longitude = geolocation.Longitude
                };
            }

            if (PermissionGranted(permissionStatus))
            {
                GetCurrentWeatherCommand.Execute();
                GetForecastCommand.Execute();
            }
        }
Esempio n. 2
0
 public void Init()
 {
     GetCurrentWeatherCommand.Execute();
 }