question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebView iOS cookie issue

See original GitHub issue

Tell us about the problem

web-view for iOS is not automatically passing the cookies after the recent change of iOS UIWebView to WKWebView(https://github.com/NativeScript/NativeScript/pull/5093)

Previous Nativescript “web-view” was using UIWebView and native code cookies(using NSURLConnection/NSURISession) is shared and the application worked fine.

We are using this feature for authentication cookies to be shared between native and web-view.

Also, I don’t see easy way to set the http cookie for the current NativeScript web-view ui control.

Take a look the following link for ways to set cookie for WKWebView

https://stackoverflow.com/questions/26573137/can-i-set-the-cookies-to-be-used-by-a-wkwebview

Which platform(s) does your issue occur on?

iOS

Please provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it)
$ tns --version
3.5.0-2017-12-20-10289
  • Cross-platform modules: (check the ‘version’ attribute in the node_modules/tns-core-modules/package.json file in your project)
  "typings": "tns-core-modules.d.ts",
  "version": "3.4.0"
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
   "tns-ios": {
      "version": "3.4.0-rc-2017-12-4-1"
    }
<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
itsEspencommented, Mar 5, 2020

This is how I solved it.

Template: <WebView [src]="html"></WebView>

OnNgInit:

this.http.get(url, {withCredentials: true, responseType: 'text'})
  .subscribe(res =>{
            this.html = res;
        });
0reactions
manoldonevcommented, Nov 21, 2019

The native method signature is setCookie:completionHandler: and it is translated to setCookieCompletionHandler(cookie: NSHTTPCookie, completionHandler: () => void): void; in NativeScript.

Check this article here on how to have access and Intellisense for the native APIs in TypeScript.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cookies issue in web view | Apple Developer Forums
We're using webview in our iOS app to show the web page. The website contains cookies and they need to be Accepted/Declined by...
Read more >
Handle issues related to cookies when you use WebView in ...
Handle issues related to cookies when you use WebView in iOS apps to connect to the server through IP addresses,HTTPDNS:You can use WebView...
Read more >
iOS - web view cookies not set - Stack Overflow
1 Answer 1 · I tried this approach and just added my entire code and output to my question. · if in console...
Read more >
Sync Cookies Across Webviews and Native App for iOS and ...
The focus here is fully enabling the Cookies to be shared between the Native and the Webview. Hence we use the final solution...
Read more >
WKWebView does not provide a way to set cookie accept policy
It seems the default cookie policy for programmatic WebViews changed? Our > > app works with iOS 12 but the login fails due...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found