I want to set alert like Safari, when user click on a video url then it will ask for to play or cancel.
currently when I click on video url(a url inside of a loaded page) it directly play the video in AVPlayer.
How do I implement it without auto-start?
This answer works in my case.
on click of downloadable link where videos will play I use below delegate of wkwebview:
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if navigationAction.navigationType == WKNavigationType.linkActivated {
print("downloadable link")
// add alert here
decisionHandler(WKNavigationActionPolicy.cancel)
}else{
decisionHandler(WKNavigationActionPolicy.allow)
}
here(on place of add alert here) you can add the alert same like Safari and use as per your requirement.