Stripe付款后如何从Webview重定向到React Native Expo应用程序?

duc*_*tr0 3 deep-linking webview stripe-payments react-native expo

我目前正在使用 React Native Expo 开发移动应用程序。为了避免分离,我在 WebView 中使用 Stripe 仅限客户端的结账页面。

我的问题是如何将成功/取消的付款从 WebView 重定向回应用程序中的特定屏幕?

use*_*795 6

我遇到了类似的问题 - 如果您提前知道重定向网址会是什么样子...这就是我所做的...所以就我而言,让我们调用我的网址http://google.com

   render() {
      return (
      
       <WebView
         onNavigationStateChange={ 
             (e) => { 
               if(e.url == "https://www.google.com/") this.props.navigation.navigate("NewsFeed")
             }
          }
       source={{ uri: 'https://a-url-to-load' }} style={styles.WebView} />
      )
   };
  }
Run Code Online (Sandbox Code Playgroud)

当然,您应该提取该函数来执行更复杂的操作......等等

  • 谢谢你!正如已接受的答案中所建议的,这比深度链接回应用程序要简单得多。 (2认同)