检查Google Maps应用是否已安装在react-native iOS中

San*_*aha 3 react-native react-native-ios

我尝试使用npm模块,react-native-check-app-install但无法始终获得错误的结果。

还尝试使用react-native-installed-apps来获取手机中安装的应用程序列表,但此返回的列表始终为空。

lfk*_*wtz 6

您确定要声明URL方案吗?

https://developers.google.com/maps/documentation/ios-sdk/start#step_6_declare_the_url_schemes_used_by_the_api

完成此操作后,您不需要其他软件包即可检查是否可以打开Goog​​le地图。您可以只使用链接模块。

Linking.canOpenURL('comgooglemaps://?center=40.765819,-73.975866')
.then((canOpen) => {
    if (canOpen) { console.log('open google maps'); } else { console.log('open apple maps'); }
});
Run Code Online (Sandbox Code Playgroud)