Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
WKHTTPCookieStore getAllCookies no siempre llama al controlador de finalización

Nuestra aplicación permite iniciar sesión a través de SSO, lo que hacemos activando una vista de WKWebKit en una URL particular que se comunica con nuestro servidor y, finalmente, redirige a una URL que estamos esperando. Durante este proceso, recibimos una cookie que debemos transferir a nuestro SessionManager; sin embargo, cuando intentamos obtener las cookies de WKHTTPCookieStore, no siempre recibimos la devolución de llamada. Aquí hay algo de código:

 func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { let httpCookieStore = WKWebsiteDataStore.default().httpCookieStore httpCookieStore.getAllCookies { (cookies) in // This block not always called!!! } }

Esto suele ocurrir en la instalación inicial de la aplicación en el dispositivo y casi siempre se puede reproducir en el dispositivo, pero no en el simulador.

En este punto, he intentado todo lo que se me ocurre, pero no sé por qué a veces se llama a la devolución de llamada, pero no siempre.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Para ver todas las cookies puedes usar este código

 import UIKit import WebKit class ViewController: UIViewController, WKNavigationDelegate { var webView: WKWebView? override func viewDidLoad() { super.viewDidLoad() let configuration = WKWebViewConfiguration() webView = WKWebView(frame: .zero,configuration:configuration) self.view = webView } override func viewDidAppear(_ animated: Bool) { let url = URL(string: "YOUR URL") let request = URLRequest(url: url!) webView?.navigationDelegate = self webView?.addObserver(self, forKeyPath: "URL", options: [.new, .old], context: nil) self.webView?.load(request) } override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { if let newValue = change?[.newKey] as? Int, let oldValue = change?[.oldKey] as? Int, newValue != oldValue { print("NEW",change?[.newKey]) } else { print("OLD",change?[.oldKey]) } webView?.configuration.websiteDataStore.httpCookieStore.getAllCookies { cookies in for cookie in cookies { print(cookie) } } } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!