React native 应用程序处于暂停或关闭状态时Url为空
我的问题不同,我不知道我哪里做错了React native 应用程序处于暂停或关闭状态时Url为空,react-native,React Native,我的问题不同,我不知道我哪里做错了 componentDidMount() { Linking.addEventListener('url', this._handleOpenURL); AppState.addEventListener('change', this._handleAppStateChange); }, componentWillUnmount() { Linking.removeEventListener('url', this._handleOpenURL); AppSta
componentDidMount() {
Linking.addEventListener('url', this._handleOpenURL);
AppState.addEventListener('change', this._handleAppStateChange);
},
componentWillUnmount() {
Linking.removeEventListener('url', this._handleOpenURL);
AppState.removeEventListener('change', this._handleAppStateChange);
},
_handleOpenURL(event) {
console.log(event.url);
}
_handleAppStateChange = async (nextAppState) => {
Linking.getInitialURL().then(url => {
alert("upper----"+url)
//this.navigate(url);
});
const url = await Linking.getInitialURL();
alert("_handleAppStateChange url is"+url);
}
}
我用过这个片段
所以问题是。当我打开我的应用程序时。现在我转到浏览器,在搜索栏中输入url/链接。
在这段时间里,我的应用程序会暂停或进入后屏幕。
不是我点击了网址。应用程序已打开,没有问题,但URL将为空
Linking.getInitialURL().then(url => {
alert("url is----"+url)
//this.navigate(url);
});
现在,当我关闭应用程序并将其从最近打开的应用程序中清除,然后点击url/链接和应用程序opensup,我可以看到url
现在,如果我点击链接,它也会显示在onStateChange日志中
谁能告诉我我错过了什么。因为我们在点击链接之前不会清除应用程序。它应该在Resume上获取url