小编ver*_*per的帖子

带有 React-Navigation 的 React-Native Deeplinks 不起作用

我一直在尝试通过 react-navigation (v5) 为我的应用设置深层链接,所以我遵循了他们的说明。我编辑了我的应用程序委托以包含我需要的包和深层链接/通用方法,我从他们的网站复制粘贴。之后他们说要将方案添加到项目的配置中,所以我按照他们npx uri-scheme add playlist --ios在终端中所说和写的内容 进行操作,我可以确认它有效,因为我可以做到npx uri-scheme list并且我回来了

› iOS: Schemes for config: ./ios/audvice-tvOS/Info.plist
› playlist://

› Android: Schemes for config: ./android/app/src/main/AndroidManifest.xml
› ${applicationId}://
› ${applicationId}://
› ${applicationId}://
› https://
Run Code Online (Sandbox Code Playgroud)

现在我只需要通过运行npx uri-scheme open playlist://asdf --ios or来测试它xcrun simctl openurl booted playlist://asdf,当我这样做时,我会返回以下错误:

› iOS: Attempting to open URI "playlist://1234" in simulator
An error was encountered processing the command (domain=NSOSStatusErrorDomain, code=-10814):
The operation couldn’t be completed. (OSStatus error -10814.)

Aborting run
An unexpected …
Run Code Online (Sandbox Code Playgroud)

deep-linking ios react-native react-navigation

5
推荐指数
1
解决办法
536
查看次数

如果应用程序关闭,React-Native 深度链接将不起作用(React-Navigation v5)

我已经使用 React Navigation V5 为我的应用程序实现了深层链接。

我有一个关于深层链接的问题。如果应用程序被关闭(杀死)并且通过深层链接打开它,它将带我到主屏幕,而不是它必须带我到的屏幕。

这是我的链接配置,根据我在文档(此处)中读到的内容,我将 URL 从getInitialUrl函数传递到订阅,在这里 const onReceiveURL = ({ url }) => listener(url); 它应该将 URL 解析为有效的导航状态并将我带到它的屏幕到。不过,我可能对订阅的工作方式有误解。

感谢任何帮助,提前致谢!

const linking = {
    prefixes: ['appName://', 'app.appName.com://', APP_WEB_DOMAIN],
    async getInitialURL() {
      // Check if app was opened from a deep link
      const url = await Linking.getInitialURL();
      if (url != null) {
        return url;
      }
    },
    subscribe(listener) {
      const onReceiveURL = ({ url }) => listener(url);

      Linking.addEventListener('url', onReceiveURL);

      return () => {
        // Clean up the …
Run Code Online (Sandbox Code Playgroud)

deep-linking reactjs react-native react-navigation

5
推荐指数
1
解决办法
2000
查看次数

React Navigation v5 使用自定义标头

如果我在 React-Navigation V5 中将标头设置为关闭,是否可以拥有自定义标头?

我尝试过,但是headerLeftandheaderRight似乎什么也没做,例如,我有以下内容:

<Stack.Screen
  component={UploadStack}
  name="UploadStack"
  options={{ headerShown: false }}
/>
Run Code Online (Sandbox Code Playgroud)

然后在我的UploadStack,我有

<Stack.Navigator initialRouteName="TrackUploadSelectionScreen">
      <Stack.Screen
        name="AddToPlaylistScreen"
        component={AddToPlaylistScreen}
      />
      <Stack.Screen
        name="TrackUploadSelectionScreen"
        component={TrackUploadSelectionScreen}
        options={{
          title: t('general.selectToUpload'),
          headerLeft: () =>
            Platform.select({
              ios: () => (
                <NavigationHeader.TextButton
                  label={t('general.cancel')}
                  onPress={navigation.goBack()}
                />
              ),
              android: () => (
                <NavigationHeader.IconButton
                  iconName="times"
                  label={t('general.cancel')}
                  onPress={navigation.goBack()}
                />
              )
            })
        }}
      />
</Stack.Navigator>
Run Code Online (Sandbox Code Playgroud)

但它没有创造任何东西

react-native react-navigation

2
推荐指数
1
解决办法
2万
查看次数