Browse Source

App now gracefully handles the location service being turned off in the Windows OS.

pull/521/head
David Britch 7 years ago
parent
commit
0f0a7fb698
1 changed files with 13 additions and 4 deletions
  1. +13
    -4
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs

+ 13
- 4
src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs View File

@ -1,13 +1,15 @@
using eShopOnContainers.Core.Models.Location;
using eShopOnContainers.Core.Services.Dependency;
using eShopOnContainers.Core.Services.Location;
using eShopOnContainers.Core.Services.Settings;
using eShopOnContainers.Core.ViewModels.Base;
using eShopOnContainers.Services;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using eShopOnContainers.Core.Services.Dependency;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace eShopOnContainers
@ -76,10 +78,17 @@ namespace eShopOnContainers
// Delay getting the position to ensure that the UI has finished updating
await Task.Delay(2000);
var position = await locator.GetPositionAsync();
try
{
var position = await locator.GetPositionAsync();
_settingsService.Latitude = position.Latitude.ToString();
_settingsService.Longitude = position.Longitude.ToString();
_settingsService.Latitude = position.Latitude.ToString();
_settingsService.Longitude = position.Longitude.ToString();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
}
else
{


Loading…
Cancel
Save