I am trying to open google from using react-native Linking.openUrl in my app.
what happens is, it opens the browser but right after opening the browser it closes the browser and my app.
my code
const url = "https://www.google.com";
try {
const canOpen = await Linking.canOpenURL(url);
console.log(canOpen); // it returns true
if (canOpen) {
Linking.openURL(url);
}
} catch (error) {
console.log("the error is ", error);
}
I tried with other urls as well and the same happens. Can open is true, It opens a browser but right after opening the browser, it closes the browser and my app.
I did search online but could not find any potential solution.
2
Answers
After testing different cases and solutions. I found out that, there was an issue with the emulator I was using. When I used it with an actual device It was working fine.
Thanks for your comments and answer
Kindly try this and see if there is any error occured: