私のXamarinフォームアプリケーションにマップを追加しようとしています。私は、アプリを開くと、それはエラーを次のように:XamarinフォームのGeolocationException
Plugin.Geolocator.Abstractions.GeolocationExceptionが
を投げてきたジオロケーションエラーが発生しました:不正な
初めて、ポップアップ私は場所にアクセスできるかどうか尋ねるためにアプリを実行すると、表示され、私は受け入れた。私はアプリを実行すると、ポップアップはもはや表示されません、それは単なるエラーです。 ItemsPageは、アプリがクラッシュする最初の画面です。 .plistファイルを含めました。私はXamarinからthisガイドをフォローしていました。
Main.cs(IOS)
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate"); // error thrown here
}
}
ItemsPage.xaml
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
x:Class="Divco.ItemsPage"
Title="{Binding Title}"
x:Name="BrowseItemsPage">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Logout" Command="{Binding LogoutCommand}"/>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<StackLayout>
<!--<maps:Map WidthRequest="320" HeightRequest="300"
x:Name="MyMap"
IsShowingUser="false"
MapType="Street"/>-->
<ListView x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" RefreshCommand="{Binding LoadItemsCommand}" IsPullToRefreshEnabled="true" IsRefreshing="{Binding IsBusy, Mode=OneWay}" CachingStrategy="RecycleElement" ItemSelected="OnItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10">
<Label Text="{Binding id}" LineBreakMode="NoWrap" Style="{DynamicResource ListItemTextStyle}" FontSize="16" />
<Label Text="{Binding description}" LineBreakMode="NoWrap" Style="{DynamicResource ListItemDetailTextStyle}" FontSize="13" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
AppDelegate.cs
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
Xamarin.FormsMaps.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
のInfo.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>{Hidden}</string>
<key>CFBundleName</key>
<string>{Hidden}</string>
<key>CFBundleIdentifier</key>
<string>{Hidden}</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>MKDirectionsRequest</string>
<key>LSItemContentTypes</key>
<array>
<string>com.apple.maps.directionsrequest</string>
</array>
</dict>
</array>
<key>MKDirectionsApplicationSupportedModes</key>
<array>
<string>MKDirectionsModeCar</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access always to location.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access location when open.</string>
</dict>
</plist>
結局、私は、ユーザーの現在位置を表示するようにXAMLでマップ部分をコメントアウトしたいと思います。
を参照してください、あなたは)(Xamarin.FormsMaps.Initを追加しました。 AppDelegateで? –
@SteveChadbourneはい。それを質問に追加します。 –