1

任何人都知道为什么当我将应用程序提交到商店时,我的代码总是出错。一切都在开发设备上运行得很好。应用能力: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));
            }
        }
    }
4

1 回答 1

0

如果您可以提供测试报告中给出的信息,那么我们可能会提供更好的帮助,尽管他们的文件通常是不言自明的。

认证要求是MSDN上的文档,与使用位置的应用程序相关的要求在第 2.7 节中介绍。

于 2013-10-18T15:30:39.183 回答