0

我需要在点击通知栏上打开音频单页


  componentDidMount() {
    Linking.getInitialURL().then((url) => this.handleUrl({ url: url }));
    Linking.addEventListener('url', this.handleUrl);
  }

  componentWillUnmount() {
    Linking.removeEventListener('url', this.handleUrl);
  }

  handleUrl = async (data) => {
    if (data.url === 'trackplayer://notification.click') {
      const slug = await TrackPlayer.getCurrentTrack()
      console.log(slug);
      RootNavigation.navigate({
        routeName: 'Player',
        params: {
          slug: slug,
        },
        key: 'player' + slug
      })  
    }
  };

https://github.com/DoubleSymmetry/react-native-track-player/issues/346#issuecomment-450512039 我试过这个工作,但现在我想从App.js文件打开页面(导航显示未定义)

我也试过这个https://stackoverflow.com/a/65299433/12716902

4

0 回答 0