diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md index a100722..474e00c 100644 --- a/ios/CHANGELOG.md +++ b/ios/CHANGELOG.md @@ -19,3 +19,7 @@ The iOS app, `ios/`. Format: [Keep a Changelog](https://keepachangelog.com/en/1. - A widget for the home screen and lock screen: the unread count, and the episode you were on with a button to resume or pause it (#428). - The icon's count stays right with the app closed: ipx sends it to the phone when it changes, once its `[push]` is set up, in place of waiting for iOS's background refresh (#433). - Presses are felt: a light tap on play, pause, flag and pull to refresh, a success on marking read, a warning with an error (#430). + +### Fixed + +- A question the page asks before going ahead (deleting a file, sharing an address that carries your access) is shown with Cancel and OK, rather than answered Cancel at once with nothing shown (#453). diff --git a/ios/Sources/WebViewController.swift b/ios/Sources/WebViewController.swift index ab4a829..fcf9b10 100644 --- a/ios/Sources/WebViewController.swift +++ b/ios/Sources/WebViewController.swift @@ -122,6 +122,20 @@ final class WebViewController: UIViewController, WKNavigationDelegate, WKUIDeleg decisionHandler(.cancel) } + /// The page's confirm(): without this WebKit answers Cancel at once and shows nothing, so + /// anything that asked first (deleting a file, sharing a Patreon address) could not go ahead + /// in the app (#453). The page uses no alert() or prompt(). + func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, + initiatedByFrame frame: WKFrameInfo, + completionHandler: @escaping @MainActor (Bool) -> Void) { + // Another alert already up cannot have this one over it: answered as before, Cancel. + guard presentedViewController == nil else { return completionHandler(false) } + let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "Cancel", style: .cancel) { _ in completionHandler(false) }) + alert.addAction(UIAlertAction(title: "OK", style: .default) { _ in completionHandler(true) }) + present(alert, animated: true) + } + func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { let host = Server.url?.host ?? "the server"