I have successfully implemented a universal link that opens up a specific page in my app (if the app is turned off). The problem is that if the app is running in the background, the eventListener is not being called. Here is the code:
import {Linking} from 'react-native';
export default class App extends React.Component {
async componentDidMount(){
Linking.addEventListener('url', this._handleOpenURL);
let url = await Linking.getInitialURL();
if (url) {
console.log('MOUNT GET INIT URL','initial url ' + url);
}
}
_handleOpenURL = (event) => {
console.log("in _handleOpenURL", event.url)
}
}
MOUNT GET INIT URL
is successfully logged to the console. in _handleOpenURL
is never logged. It seems other people on the internet have had this problem but no one has answered it. Does anyone know what to do?