SDKLauncher-iOS
SDKLauncher-iOS copied to clipboard
How to detect user pressing on link inside the book
Hey,
I'm using readium and every thing is working just fine! What i need to do is to detect a user press on a link that opens the safari something like: "Click here to see more books" - opens new safari page with that link After i detects it i need to make a change to the url and after that open it with the changes.
What should i do?
Update:
Several books contains hyper link and what i want to do is to replace the link with custom link of my own.
I manage to get the page content and replace the link, but when i load the webView with the new content i cant go back or to the next page because the html is not reader.html anymore and it not response to the JS commands of Readium.
I already tried to recognise the navigationType but what i get is pageDidChange and it recognise it as UIWebViewNavigationTypeOther so it didn't work.
So the only way I can think of, is to replace the current file with my configured file but the file path is http://127.0.0.1:port/file.xhtml. and i didn't figure out a way to replace file in that kind of path
Hope you can help me with this.
Absolute HTTP hyperlinks in EPUB HTML content documents are processed specifically by readium-shared-js
, see window.open(href, '_blank')
here:
https://github.com/readium/readium-shared-js/blob/dd645d38f8c29e01b386cd2b2864379358e91ed6/js/views/internal_links_support.js#L210
You should be able to capture / intercept this "_BLANK" navigation request from the native webview API.
You could do something like this:
- Use the WKUIDelegate like so ->
webView.UIDelegate = self
- In
(WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
you can usenavigationAction.request.URL.absoluteString
to get the URL being called, and just change it, if you need.