KMZ / Google 地球 iOS 应用程序的 LSApplicationQueriesSchemes

LSApplicationQueriesSchemes for KMZ / Google Earth iOS App

我的 iOS 应用程序中有一个 KMZ 文件。我试图在 iOS Google 地球应用程序中打开它。我想不出正确的 URL 方案。

查看iTunes下载的"Google Earth 7.1.6.ipa"里面,发现softwareVersionBundleId为:

com.google.b612

我将以下 LSApplicationQueriesSchemes 添加到 info.plist:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>file</string>
    <string>comgoogleb612</string>
</array>

当我尝试打开 KMZ 文件时收到以下错误消息:

-canOpenURL: failed for URL: "file:///var/mobile/Containers/Data/Application/537CF335-3DA5-46E0-A671-169645593E38/Documents/apps/google_earth_tour.kmz" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

-canOpenURL: failed for URL: "comgoogleb612:///var/mobile/Containers/Data/Application/537CF335-3DA5-46E0-A671-169645593E38/Documents/apps/google_earth_tour.kmz" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

comgoogleb612file 不是 Google 地球定义的 URL 方案。

Google 地球应用程序在 Info.plist 中包含以下相关信息:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>CFBundleURLName</key>
        <string>geo</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>comgoogleearthgeo</string>
            <string>geo</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>CFBundleURLName</key>
        <string>com.google.b612</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>comgoogleearth</string>
            <string>kml</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>CFBundleURLName</key>
        <string>com.google.b612.kmz</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>comgoogleearthz</string>
            <string>kmz</string>
        </array>
    </dict>
</array>

应用程序定义的自定义方案是 CFBundleURLSchemes 键下列出的值。

鉴于此,我将使用 comgoogleearthzkmz URL 方案来启动 Google Earth。

但更好的方法是使用 UIActivityViewControllerUIDocumentInteractionController 并让用户选择他们希望对 KMZ 文件执行的操作。