我构建了一个本机应用程序,如果用户单击链接,则该应用程序将打开默认的Web浏览器并转到该链接。
Linking.openURL(notification.link);
如果用户从android或ios设备上按下后退按钮,有什么方法可以检测到后退?
您可以在react native中为其添加一个侦听器。
总共有4个相同的列表器。
试试下面的代码
componentWillMount(){
const didFocusSubscription = this.props.navigation.addListener(
'didFocus',
payload => {
console.warn('didFocus ', payload);
# just write your code/call a method here which you want to execute when the app comes from background
}
);
}
完成后,请不要忘记删除它。
componentWillUnmount(){
didFocusSubscription.remove();
}
更多,您可以阅读here。谢谢:)