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

How to redirect to React Native Expo app from Webview after Stripe payment?

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

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

我想你想在这里做的是使用 Deep Links 作为 return URL 这应该让你回到应用程序 - 你可以使用路径指定它应该降落的确切位置。

我有一个类似的问题 - 如果你提前知道重定向 url 会是什么样子...这就是我所做的......所以在我的情况下让我打电话给 url 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} />
      )
   };
  }

当然你应该提取那个函数来做更复杂的事情......等等