我正在 Flutter 中使用 url_launcher 包在 Android 和 iOS 上打开 Google 地图或 Apple 地图。到目前为止,它在Android设备上完美运行;但是,我在尝试在 iOS 上启动时遇到了问题。如果适用,我想为用户提供选择(可能从底部工作表?)要使用哪个地图应用程序的选项,但现在我只关心使其在 iOS 上运行。
\n\n我已在 Info.plist 文件中包含了必要的 LSApplicationQueriesSchemes。我研究了谷歌和苹果的正确网址方案,我相信它们是正确的(当然有待审查)。我已经咨询过有关此问题的其他 SO 帖子,但没有找到运气。
\n\nFuture<bool> launchMap(String addressLine1) async {\n String urlGoogleMaps =\n "https://www.google.com/maps/search/?api=1&query=$addressLine1";\n String urlAppleMaps = "https://maps.apple.com/?query=$addressLine1";\n if (await canLaunch(urlGoogleMaps)) {\n print(\'launching google url\');\n await launch(urlGoogleMaps);\n return true;\n } else if (await canLaunch(urlAppleMaps)) {\n print(\'launching apple url\');\n await launch(urlAppleMaps);\n return true;\n } else {\n throw \'Could not launch maps\';\n }\n }\nRun Code Online (Sandbox Code Playgroud)\n\n如前所述 - 在我的 Info.plist 中:
\n\n<key>LSApplicationQueriesSchemes</key>\n …Run Code Online (Sandbox Code Playgroud)