检查是否在具有React Native的设备上安装了某个应用程序

Xav*_* C. 7 react-native

从我的应用程序,我正在尝试检查是否安装了另一个应用程序(在我的示例中,谷歌地图).所以我试着用:

Linking.canOpenURL('comgooglemaps://?daddr=' + address + '&directionsmode=walking').then(supported => {...}).catch(err => console.error('An error occurred', err));
Run Code Online (Sandbox Code Playgroud)

但它返回它不支持,所以它就像没有安装谷歌地图.你知道解决这个问题的方法吗?

Jea*_*ser 2

我假设您在使用 iOS 时遇到了这个问题。

从 iOS 9 开始,您必须声明要使用的 URL 方案。请参阅另一个答案的详细信息

或官方文档:https://developers.google.com/maps/documentation/ios-sdk/start#step_7_declare_the_url_schemes_used_by_the_api