我的iOS应用中有一个KMZ文件。我试图在iOS Google地球应用中打开它。我无法找出正确的网址方案。
查看" Google地球7.1.6.ipa"通过iTunes下载,我发现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.)"
答案 0 :(得分:0)
comgoogleb612
和file
不是Google地球定义的网址计划。
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
键下列出的值。
鉴于此,我会使用comgoogleearthz
或kmz
网址方案来启动Google地球。
但更好的方法是使用UIActivityViewController
或UIDocumentInteractionController
并让用户选择他们想要对KMZ文件执行的操作。