Press ESC to close

Xamarin iOS Opening Locaiton

You may also want to use maps in your Xamarin Forms applications. Maybe you want to get the location information of the person here. For this you need to get permission from the phone that the application is installed. I showed you how to do this for Android. In this article I will talk about how to do this for iOS. If you have not made adjustments in this article, it is likely that you will get an error like the one below.

On iOS 8.0 and higher you must set either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in your Info.plist file to enable Authorization Requests for Location updates!”

We also need to make iOS adjustments for this. In fact, these settings are available in detail in Yiğit Özaksüt Xamarin Advanced Education Courses. I decided to write an article dedicated to the mistake you took. You can access the video here.

If you are getting this error you already have the Nuget package installed and you need to set the map page but if you can not do this, you can get the article I wrote about this topic here. The reason for this error is that we need to get permission to use the location information on iOS, which gives us this error. First we need to initiate Xamarin.FormsMaps into the AppDelegate.cs file on the iOS layer. This should be our code block;

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            global::Xamarin.FormsMaps.Init();
            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }

Then we came to the permission section. We are exporting permissions from info.plist file. While it is very easy to do this via Xamarin Studio or Xcode, we need to open it via xml editor by right clicking on the info.plist and clicking on open with with Visual Studio. After that, we need to add the codes below.Then we came to the permission section. We are exporting permissions from info.plist file. While it is very easy to do this via Xamarin Studio or Xcode, we need to open it via xml editor by right clicking on the info.plist and clicking on opne with with Visual Studio. After that, we need to add the codes below.

<key>NSLocationAlwaysUsageDescription</key>
    <string>Can we use your location</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>We are using your location</string>

We now have the necessary permissions. Our map is also available on the iOS platform. If you have questions about your mind, you can contact me by comment or mail.

Leave a Reply

Your email address will not be published. Required fields are marked *