Description
Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 108.45 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.4.0 - ~/.nvm/versions/node/v11.4.0/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v11.4.0/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
Android SDK:
API Levels: 28
Build Tools: 28.0.3
System Images: android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5199772
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
react: 16.6.3 => 16.6.3
react-native: 0.58.3 => 0.58.3
npmGlobalPackages:
react-native-cli: 2.0.1
Description
soon after Webview loads Session get expired.
WebView works fine without useWebKit={true}. but here my e.nativeEvent.data is JsonObject. hence output will be "Object object" as it accepts only string.
with useWebKit={true} I am able get my data, but gets session expired issue
Reproducible Demo
class TestLibrary extends Component{
constructor(props){
super(props);
this.state={
clicked:this.props.clicked,
DEFAULT_URL:'https://www.facebook.com',
componentLoading:true,
appLoading: false,
};
this.handleCloseButton = this.handleCloseButton.bind(this);
this.handleMessage = this.handleMessage.bind(this);
}
componentDidMount(){
const {jwtToken, app, redirectReq, extraParams} = this.props;
let extraParamsModified=this.prepareExtraParam(extraParams);
this.fetchFastLinkUrl(jwtToken,app,redirectReq,extraParamsModified);
}
fetchFastLinkUrl = (jwtToken,app,redirectReq,extraParams) => {
const url = "https://test.testbox.dummy.com/authenticate/restserver";
let details = {
'jwtToken': jwtToken,
'app': app,
'redirectReq':redirectReq,
'extraParams':{extraParams}
};
let formBody = [];
for (let property in details) {
let encodedKey = encodeURIComponent(property);
let encodedValue = encodeURIComponent(details[property]);
formBody.push(encodedKey + "=" + encodedValue);
}
formBody = formBody.join("&");
fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
},
credentials: 'include',
body: formBody
}).then((response) => {
return response.json();
})
.then((responseData) => {
console.log("Hello Prathuu");
console.log(responseData);
const newUrl='https://test.testbox.dummy.com'+responseData.finappAuthenticationInfos[0].finappURL;
console.log(newUrl);
this.setState({loading:false, DEFAULT_URL:newUrl,clicked:!this.state.clicked});
})
.done();
};
handleCloseButton = () => {
this.props.close();
};
handleMessage = (e) => {
console.log(e);
const obj=e.nativeEvent.data;
this.props.onCallBack(obj);
}
render() {
return (
<View style={{flex: 1}}>
<WebView
useWebKit={true}
source={{uri: this.state.DEFAULT_URL}}
ref={ref => { this.web = ref; }}
style={{marginTop: 20}}
onMessage={this.handleMessage}
/>
<TouchableHighlight style={[styles.buttonContainer, styles.loginButton, styles.container]} onPress={this.handleCloseButton}>
<Text style={styles.loginText}>Close</Text>
</TouchableHighlight>
</View>
);
}
}
export default TestLibrary;