Search code examples
iosgoogle-earthkmz

LSApplicationQueriesSchemes for KMZ / Google Earth iOS App


I have a KMZ file inside my iOS app. I'm trying to have it open inside the iOS Google Earth app. I'm unable to figure out the correct URL scheme.

Looking inside the "Google Earth 7.1.6.ipa" downloaded by iTunes, I found that the softwareVersionBundleId is:

com.google.b612

I added the following LSApplicationQueriesSchemes to info.plist:

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

I get the following error messages when I try to open a KMZ file:

-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.)"

Solution

  • comgoogleb612 and file are not URL schemes defined by Google Earth.

    The Google Earth app has the following relevant info in it's 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>
    

    The custom schemes defined by the app are the values listed under the CFBundleURLSchemes keys.

    Given this, I would use the comgoogleearthz or kmz URL scheme to launch Google Earth.

    But a better approach would be to use UIActivityViewController or UIDocumentInteractionController and let the user choose what they wish to do with the KMZ file.