任何人都知道为什么当我将应用程序提交到商店时,我的代码总是出错。一切都在开发设备上运行得很好。应用能力:LOCATION, MAP, IDENTITY_DEVICE, IDENTITY_USER, CAMERA, AUDIO, PHOTO, NETWORKING, PROXIMITY, PUSH_NOTIFICATION, SENSORS
private readonly Geolocator _geolocator = new Geolocator { DesiredAccuracy = PositionAccuracy.Default, MovementThreshold = 100 };
private async Task GetCurrentPosition()
{
//Get current location
try
{
_done.WaitOne();
var position = await _geolocator.GetGeopositionAsync();
if (position != null)
{
// Get detail address
var query = new ReverseGeocodeQuery { GeoCoordinate = new GeoCoordinate(position.Coordinate.Latitude, position.Coordinate.Longitude) };
query.QueryCompleted += OnQueryCompleted;
_done.Reset();
query.QueryAsync();
}
}
catch (Exception ex)
{
if (ex.Message.Contains("Operation aborted"))
{
if (MessageBox.Show(AppResources.LocationServiceErrorMsg, AppResources.ApplicationTitle, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-location:"));
Application.Current.Terminate();
}
else
{
Application.Current.Terminate();
}
}
}
}
private void OnQueryCompleted(object sender, QueryCompletedEventArgs<System.Collections.Generic.IList<MapLocation>> e)
{
_done.Set();
if (e.Result != null && e.Result.Count > 0)
{
App.AppData.CurrentCountry = e.Result[0].Information.Address.Country;
App.AppData.CurrentCity = e.Result[0].Information.Address.City;
App.AppData.CurrentStreet = e.Result[0].Information.Address.Street;
App.CurrentPosition = e.Result[0].GeoCoordinate;
Helper.SaveAppSetting(App.AppData);
if (string.IsNullOrEmpty(App.AppData.UserId))
{
NavigationService.Navigate(MessageBox.Show(AppResources.UserIdEmptyMsg, AppResources.ApplicationTitle, MessageBoxButton.OKCancel) == MessageBoxResult.OK
? new Uri("/Views/SettingPage.xaml?navCode=userId", UriKind.Relative)
: new Uri("/Views/MainPage.xaml", UriKind.Relative));
}
else
{
NavigationService.Navigate(new Uri("/Views/MainPage.xaml", UriKind.Relative));
}
}
}