I have the following situation: I am trying to access a page that I can only access after we have logged in with the Microsoft 2FA auth. I always got the same error "415 Unsupported Media Type" in the Safari browser. After I had deactivated "Block POP" in the Safari settings and set "Hide my IP" to OFF, everything worked fine in the Safari browser.
Now I am trying the same thing in my app in the WebView. I have already tried this code:
import UIKit
import SafariServices
class HorizonViewController: UIViewController, SFSafariViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
showWebPage()
}
func showWebPage() {
if let url = URL(string: "https://myurl") {
let safariVC = SFSafariViewController(url: url)
safariVC.delegate = self
self.present(safariVC, animated: true, completion: nil)
}
}
// Optional: SafariViewController Delegate Methoden
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
// Wird aufgerufen, wenn der Benutzer den SafariViewController schließt
controller.dismiss(animated: true, completion: nil)
}
// Sie können hier weitere Delegate-Methoden hinzufügen, falls Sie sie benötigen.
}
an also this code:
import UIKit
import WebKit
class HorizonViewController: UIViewController, WKNavigationDelegate, WKUIDelegate {
var webView: WKWebView!
override func loadView() {
// Erstellen einer Web-Konfiguration
let webConfiguration = WKWebViewConfiguration()
// Deaktivieren des Cross-Site-Trackings
webConfiguration.websiteDataStore = WKWebsiteDataStore.nonPersistent()
// Erstellen der WebView mit der obigen Konfiguration
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.navigationDelegate = self
webView.uiDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
if let url = URL(string: "https://glavid.golav.lu/") {
var request = URLRequest(url: url)
request.setValue("application/json", forHTTPHeaderField: "Accept")
webView.load(request)
}
}
// MARK: - WKNavigationDelegate
// Optional: Hier können Sie die Navigation im WebView steuern
// MARK: - WKUIDelegate
func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
if navigationAction.targetFrame == nil {
webView.load(navigationAction.request)
}
return nil
}
}
Unfortunately, I get the same error 415 after the 2FA.