check if google maps app is installed in react-native iOS

不羁的心 提交于 2019-12-23 18:24:25

问题


I tried with the npm module react-native-check-app-install but I couldn't achieved always the result is false.

Also tried with react-native-installed-apps to get the list of apps installed in the phone but this return always empty list.


回答1:


Did you make sure to declare the URL schemes?

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

Once you've done that, you don't need an additional package to check if you can open Google Maps. You can just use the Linking module.

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


来源:https://stackoverflow.com/questions/47652375/check-if-google-maps-app-is-installed-in-react-native-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!