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

Cookies disable in for iOS #449

Closed
mayuriruparel opened this issue Jul 10, 2020 · 3 comments
Closed

Cookies disable in for iOS #449

mayuriruparel opened this issue Jul 10, 2020 · 3 comments

Comments

@mayuriruparel
Copy link

I am using webview for payment gateway for one of my client. flutter_inappwebview 4.0.0+4

It is working perfectly for android in this plugin but when I run on iOS it is not working. Payment gateway error shows that cookies are disable in your browswer.

Here is the code.

body: InAppWebView( initialUrl: weburl, initialOptions: InAppWebViewGroupOptions(

  ios: IOSInAppWebViewOptions(
    sharedCookiesEnabled: true,
  ),

  crossPlatform: InAppWebViewOptions(
    debuggingEnabled: true,
    javaScriptEnabled: true,

  )

),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;

},
onLoadStart: (InAppWebViewController controller, String url) {
if (url == successURL) {
Navigator.of(context).pushReplacementNamed('/NormalOrderSuccess',
arguments: RouteArgument(
heroTag: widget.routeArgument.heroTag, param: order));
} else if (url == failURL) {
Payment payment = order.payment;
payment.status = 'fail';
order.payment = payment;
Navigator.of(context).pushReplacementNamed(
'/NormalOrderSuccess',
arguments: RouteArgument(
heroTag: widget.routeArgument.heroTag, param: order));
}

},
onLoadStop: (InAppWebViewController controller, String url) async {
List cookies = await _cookieManager.getCookies(url: url);
cookies.forEach((cookie) {
print(cookie.name + " " + cookie.value);
});
},
onProgressChanged: (InAppWebViewController controller, int progress) {

},
),

)), );

@blasko
Copy link

blasko commented Jul 15, 2020

Running into this as well. Works fine on Android, however on iOS, cookies are not set.

@corcoran
Copy link

Also running into this -- cannot get cookies in iOS using CookieManager. Using javascript as a workaround:

  Future<String> getCookieWithJs(
      String key, InAppWebViewController controller) async {
    String cookie = await controller.evaluateJavascript(source: '''
    document.cookie
        .split('; ')
        .find(row => row.startsWith('$key'));
      ''');

    if (cookie.isNotEmpty) {
      return cookie.split('=')[1];
    }
    return null;
  }

Copy link

github-actions bot commented Nov 8, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants