Ionic iOS 地理定位

Ionic iOS Geolocation

我构建了一个使用地理定位的应用程序,但我不知道如何解决有关“使用用户位置进行跟踪”的问题。

我尝试添加 config.xml 这个但是没有任何反应...

我该如何解决这个问题?

这里我也添加了我的pod文件。我认为每次 运行 ionic 应用程序或?

时都会生成新的
<?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>

问题出在您的Info.plist,您没有请求访问用户位置的权限。错误(和解决方案)发布在您包含的控制台错误消息中。

您需要将以下内容添加到您的 Info.plist(modify/remove 根据您的个人需要):

<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>

这将告诉 iOS 您想要访问这些功能并向用户提供接受或拒绝的选项。