We can disable javaScript in WKWebKit using preference.
let preferences = WKPreferences()
preferences.javaScriptEnabled = false
let configuration = WKWebViewConfiguration()
configuration.preferences = preferences
let WebViewKit = WKWebView(configuration: configuration )
But, Is there is any way to disable the javascript in SFSafariViewController?
let config = SFSafariViewController.Configuration()
config.entersReaderIfAvailable = true
let svc = SFSafariViewController(url: self,configuration: config)
I believe there is NO way to do it. Like what you've mentioned, WKWebView
has javaScriptEnabled
.
SFSafariViewController
must have or gets the user configurations from Safari
.
To disable it using Safari
:
You can disable javascript in Mac OS X Safari by going to Safari->Preferences (Command-,). Click on the Security tab and then uncheck "Enable Javascript". Use the same process to turn javascript back on later.
Meanwhile, Apple says in their doc https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller:
The user's activity and interaction with SFSafariViewController are not visible to your app, which cannot access AutoFill data, browsing history, or website data.
Also, based in SFSafariViewController.h
, you can't do much.
So I guess it's understandable enough that you can't do further than what are there.
Hope it helps.