A
A
Andrey Myvrenik2017-10-30 12:19:15
PHP
Andrey Myvrenik, 2017-10-30 12:19:15

How to add title to requests inside WKWebView?

There is a WKWebView and some HTML text, inside of which there are img tags with links to external images. However, the problem is that access to these images requires an Authorization header with an authorization token. How to intercept these requests and add your own header?

@IBOutlet weak var wkWebView: WKWebView!

let html = "..." // HTML с изображениями и т.д.
wkWebView.loadHTMLString("<font face='GothamRounded-Bold' size='17'>\(html)</font>", baseURL: nil)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Leonid, 2019-08-02
@HappyMen

learn to stick a list of folders to the path of each subdomain and check if such a folder exists on such a path

A
Andrey Myvrenik, 2017-11-10
@gim0

Unfortunately, this cannot be done. I had to make changes to the back so that the token was inserted into the parameters of all hotlinks inside the HTML.

D
doublench21, 2017-10-30
@doublench21

There will not be any difference between loading web view from loadRequest vs loadHTMLString method, shouldStartLoadWithRequest method will be called in both cases. You can override your headers there and add a header as per your requirements.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question