【问题标题】:How do I access failed redirects in react-native webview?如何在 react-native webview 中访问失败的重定向?
【发布时间】:2021-07-04 18:23:17
【问题描述】:

我正在使用带有 React Native 的 Plaid Link Webview。 Webview 工作正常。问题是 Plaid 使用重定向来传达更改。我不知道如何访问这些重定向。我收到来自 react-native-webview 的警告说 Cannot load url plaidlink://.... 但我希望能够读取该 URL。我尝试过使用onNavigationStateChange,但这也不起作用。

【问题讨论】:

    标签: react-native react-native-webview plaid


    【解决方案1】:

    我的同事建议使用此代码:

    <WebView
          source={{
            uri: `https://cdn.plaid.com/link/v2/stable/link.html?isWebview=true&token=${linkToken}`,
          }}
          originWhitelist={['https://*', 'plaidlink://*']}
          onShouldStartLoadWithRequest={handleNavigationStateChange}
        />
    const handleNavigationStateChange = (event: any) => {
        if (event.url.startsWith('plaidlink://')) {
          console.log(event.url)
    }
    

    但是,我们也建议尽可能使用 Plaid 的官方 SDK,例如我们的 React Native SDK,而不是直接从 Plaidlink URL 读取,因为这些 URL 将来可能会发生变化。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      • 2020-01-23
      • 2023-04-05
      相关资源
      最近更新 更多