Closed erjdriver closed 4 years ago
A better seems to be to add it during the
shouldOverride
event.
I don't think that would work very well. On Android the event is triggered at a time when it is difficult to set the request headers. e.g in android.webkit.WebViewClient.shouldOverrideUrlLoading(...)
.
I think it would have to be implmented in android.webkit.WebViewClient.shouldInterceptRequest()
and it would propably only work for SDK 21+.
I think you'll run into problems on iOS, this might help: https://github.com/ryanzzff/til/blob/master/ios/wkwebview-custom-http-headers.md
I'd love to volunteer to add it but I've got no idea about ios and also how to build and manage these plugins.
The native part of iOS is inside: native-src/ios/NotaWebViewExt
To use build it to use in the plugin, you need to run the script native-src/build-ios.sh
The problem I'm running with loadUrl(url,maps)
call is that webview overrides certain headers (e.g. Accept). Crazy but true and the documentation seems to mention it.
So looks like I need to implement android.webkit.WebViewClient.shouldInterceptRequest()
and hopefully I get to set the headers explicitly.
Would this require a change to the plugin or something I can do at the app level.
If the former can you tell me the steps to get the code, build the new plugin and include it in my project - and eventually if you'd like push it back.
Thanks.
Is it possible to access the underling NS WebView or the native WebView object?
I'd like to add some custom headers before a request - maybe use nativescript-theme-utils.
I did read your earlier posts and it doesn't seem to be an ideal way.
A better seems to be to add it during the
shouldOverride
event.I'd love to volunteer to add it but I've got no idea about ios and also how to build and manage these plugins.
Just just to add a +1 request for custom headers.
Here's the native code for Android
I'll post the ios code when I get to it.
Thanks