Home > Software design >  Ionic iOS Geolocation
Ionic iOS Geolocation

Time:12-29

I build an app which use geolocation but I do not know how to do the question about to "use the users location for tracking".

I tried to add in config.xml this but nothing happened...

How can I solve this?

Here I also added my pod file. I think it get build new every time as I run the ionic app, or?

<?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>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
        <string>ShareApp</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <true/>
</dict>
</plist>

CodePudding user response:

The problem is in your Info.plist, you are not requesting the permissions to access a user's location. The error (and solution) is posted in the console error message you have included.

You need to add the following to your Info.plist (modify/remove based on your individual needs):

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Add your description for requiring permission here</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>Add your description for requiring permission here</string>

<key>NSLocationWhenInUseUsageDescription</key>
<string>Add your description for requiring permission here</string>

This will tell iOS that you would like to access these features and present the user with an option to accept or decline.

  • Related