android - 使用react-native检查手机上是否安装了Metamask应用程序

标签 android ios reactjs react-native

我正在使用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/

相关文章:

android - Google Map V21,如何以编程方式停止自动位置更新?

java - 使用 Java Prettify 实现 Android 应用语法高亮显示

java - android - 如何发送微调器的值?

ios - 更改字典数组中键的值

ios - 如何硬件加速 CSS 中的框阴影动画?

c# - UI 空闲时 iOS 后台线程变慢

javascript - react BaseTable rowSpan "flickering"

android - 如何将适配器设置为自动完成 TextView ?

javascript - 使用全选或单独选择多个复选框

reactjs - 如何获取更有用的错误消息?