Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webview with useWebKit={true} session ends cookies are not passed to the Webview. #23255

Closed
PratibhaSomashekhara opened this issue Feb 1, 2019 · 2 comments
Labels
Bug Component: WebView Related to the WebView component. Resolution: Locked This issue was locked by the bot.

Comments

@PratibhaSomashekhara
Copy link

PratibhaSomashekhara commented Feb 1, 2019

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;

@react-native-bot
Copy link
Collaborator

It looks like you are using an older version of React Native. Please update to the latest release, v0.58 and verify if the issue still exists.

The "Resolution: Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

@hramos
Copy link
Contributor

hramos commented Feb 2, 2019

The WebView component has been forked and and is now supported over at https://github.com/react-native-community/react-native-webview. Can you open your issue over there?

@hramos hramos closed this as completed Feb 2, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Feb 2, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Feb 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: WebView Related to the WebView component. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants