我正在使用react-native
构建一个应用程序。我正在使用 React Native 的 Linking API 在手机上安装的 Metamask 应用程序中打开我的网站链接。如果设备上安装了元掩码应用程序,则 Linking.opneURl(url)
可以正常工作。问题是,如果设备上未安装 Metamask,它将在浏览器中打开链接。
我想要做的是进行检查,如果设备上未安装 Metamsk 应用程序,系统将要求用户安装该应用程序,否则它应该在 Metamask 应用程序中正常打开。到目前为止,我已经使用了 linking
API 和 react-native-check-app
但没有得到我想要的结果。
最佳答案
请引用this官方文档中的部分。摘自文档:
Determine whether or not an installed app can handle a given URL. The method returns a Promise object. When it is determined whether or not the given URL can be handled, the promise is resolved and the first parameter is whether or not it can be opened.
然后您可以像这样继续实际使用:
const isInstalled = await Linking.canOpenURL("yourUrl");
关于android - 使用react-native检查手机上是否安装了Metamask应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70833283/