WebView iOS cookie issue
See original GitHub issueTell 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 thepackage.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:
- Created 6 years ago
- Comments:11 (3 by maintainers)
This is how I solved it.
Template:
<WebView [src]="html"></WebView>
OnNgInit:
The native method signature is
setCookie:completionHandler:
and it is translated tosetCookieCompletionHandler(cookie: NSHTTPCookie, completionHandler: () => void): void;
in NativeScript.Check this article here on how to have access and Intellisense for the native APIs in TypeScript.