Check if Metamask app is installed on the phone using react-native
I am building an app using react-native
. I am using react native's Linking
API to open my website link in the metamask app installed on my phone. The Linking.opneURl(url)
works fine if metamask app is installed on the device. The problem is that if Metamask is not installed on the device it opens the link in the browser.
What I want to do is to apply a check that if the Metamsk app is not installed on the device the user will be asked to install the app otherwise it should open normally in the metamask app. So far I have used the linking
API and the react-native-check-app
but I didn't get the result I wanted.
Please refer to this section in the official documentation. Extracted from the documentation:
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.
You then could go on to practical usage like this:
const isInstalled = await Linking.canOpenURL("yourUrl");