android - 如何在前台刷新原生 Deeplink 应用程序?

标签 android react-native react-native-android deep-linking

当我在 react native 上使用深度链接 android 时遇到问题。当应用程序被深层链接触发时,应用程序处于前台状态时,应用程序不会在该屏幕上刷新。例如,我想要深度链接到主屏幕,但是当我的前景在个人资料屏幕上时,我的应用程序不会刷新?

这是我的深度链接代码:

  async componentDidMount() {
    //  This for deeplinking
    if (Platform.OS === 'android') {
      Linking.getInitialURL().then(url => {
        this.navigate(url);
      });
    } else {
      Linking.addEventListener('url', this.handleOpenURL);
    }
  navigate = (url) => {
    const { navigate } = this.props.navigation;

    const route = url.replace(/.*?:\/\//g, '');
    const id = route.match(/\/([^\/]+)\/?$/)[1];
    const routeName = route.split('/')[0];
    if (id === 'yes') {
      alert(id)
    }
  }

最佳答案

我们可以使用 react native firebase 的属性,它可以检测前台、后台或应用程序中的应用程序。 documentation如果您为您的应用使用了通知。如果你没有,你可以使用 做焦点() 从 react 导航。

关于android - 如何在前台刷新原生 Deeplink 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59463531/

相关文章:

react-native - react-native 中 android 和 iOS 的图像大小

android - 无法将 Android 模拟器连接到 React Native 调试器

javascript - 从包含许多文件的文件夹中 react native 动态导入图像

android - Intent.ACTION 在第一个 # 符号后不拨号

javascript - 将数据渲染到屏幕时没有返回任何内容

android - 包 X 需要不可用的共享库 com.android.future.usb.accessory

reactjs - 使用 react 导航渲染抽屉式导航和选项卡式导航

在 Android 上升级 64 位后,Android Release 应用程序立即崩溃

android - 我在哪里为 Android 5.0 中的工具栏小部件定义 XML?

android - 使用 JSON 使用未弃用的方法将 MySQL 数据加载到 ListView 中