Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 17249

Linking.addEventListener('url') not triggered on iOS when app is running (React Native 0.73)

$
0
0

I'm building a React Native application and using the Linking API to handle deep linking.

Expected Behaviour

When the app is running (either in the foreground or background), I expect the listener Linking.addEventListener('url', callback) to be triggered when a deep link is opened. This works perfectly on Android.

Actual Behaviour on iOS

On iOS (device or simulator), the app is correctly brought to the foreground when I open a deep link. However, the listener callback is never triggered — it's as if the event is not fired.

Despite this, deep linking works fine when the app is closed — the initial URL is received via Linking.getInitialURL().

Code

function App(): JSX.Element {  useEffect(() => {    Linking.getInitialURL().then((url) => {      console.log('Init url path: '+ url);    });    const deepLinkingListener = Linking.addEventListener('url', (event) => {      console.log('Deep link event:', event.url);    });    return () => {      deepLinkingListener.remove();    };  }, []);  return <MyApp />;}

Test Case

  • App is closed

    Run: xcrun simctl openurl booted myapp://home

    ✅ Result: App opens and logs Init url path: myapp://home

  • App is already running

    Run: xcrun simctl openurl booted myapp://account

    ⚠️ Result: App comes to foreground, but no log is printed (expected log: Deep link event: myapp://account)

Environment

"react-native": "0.73-stable"Tested on both iOS Simulator (iOS 18.2) and physical devices

Question

  1. Why is Linking.addEventListener('url', ...) not triggered on iOS when the app is already running, while it works as expected on Android?
  2. Is there an iOS-specific workaround or additional setup required in React Native 0.73?

Viewing all articles
Browse latest Browse all 17249


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>