I’m currently working on a React Native project and I’m looking for guidance on how to handle external link clicks within the app. Specifically, I want to be able to detect when a user clicks on a link that leads outside of the app (e.g., a link to a website) and show a Popup/alert before they visit the link.
Could someone provide a detailed explanation or code example of how to achieve this functionality? I’d greatly appreciate any insights or pointers in the right direction.
I attempted to check using Linking.addEventListener('url', handleUrl);
in the main navigator, but I couldn’t observe the listener being triggered. Additionally, I experimented with AppState.addEventListener
, which did trigger, but I couldn’t ensure that it only triggered when the user clicked on a URL.