React Native中的onNavigationStateChange在Salesforce页面上不起作用

时间:2019-01-16 22:52:07

标签: android ios react-native salesforce wkwebview

我们使用WKWebView渲染Salesforce聊天页面,当我们尝试单击任何链接并导航到其他页面时,未调用 onNavigationStateChange 方法。

试图在_onNavigationStateChange中打印日志,但未调用它。

class Feed extends Component {   constructor() {
    super();   }


  **_onNavigationStateChange(webViewState){
    console.log(webViewState.url)   }**


  render() {
    return (
      <WKWebView
        startInLoadingState
        renderLoading={() => (
          <View
            style={{
              flex: 1,
              flexGrow: 1,
              backgroundColor: 'white',
              alignItems: 'center',
              justifyContent: 'center',
            }}
          >
            <ActivityIndicator size="large" color="#FCC934" />
          </View>
        )}
        onNavigationStateChange={this._onNavigationStateChange.bind(this)}
        javaScriptEnabled = {true}
        domStorageEnabled = {true}    

        injectedJavaScript={`window.onload = setTimeout(function() {
          document.querySelectorAll('[title="Title"], .toggleNav').forEach(function(item) { item.style.display = 'none' })
        }, 5000)`}
        source={{
          uri: Platform.OS === 'ios' ? `${APIUrls.MY_FEED_RETURL}?iosri=6272-2u28282820&iospref=web` : `${APIUrls.MY_FEED_RETURL}`,
          headers: {
            Authorization: `Bearer ${decodeURIComponent(this.props.accessToken)}`,
          },
        }}



        onError={error => {
          console.log(error)
          const err = CircularJSON.stringify(error);
          const errTruncated = err.substring(0, 500);
          alert(
            `${'Oops! something went wrong. Please try again this operation. Error Details: ' +
            '\n' +
            '\n'}${errTruncated}`
          );
        }}
      />
    );   } }

export default connect(mapStateToProps)(Feed);

0 个答案:

没有答案