diff --git a/CHANGELOG.md b/CHANGELOG.md index e5716690d..f57943dce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased 2025-02 +- Share files generated by webxdc apps directly (#2606) - Tweak menu order (#2604) - Fix: Preserve filenames on sharing (#2605) diff --git a/deltachat-ios/Controller/WebxdcViewController.swift b/deltachat-ios/Controller/WebxdcViewController.swift index 558bf6f2e..e43020680 100644 --- a/deltachat-ios/Controller/WebxdcViewController.swift +++ b/deltachat-ios/Controller/WebxdcViewController.swift @@ -528,6 +528,19 @@ extension WebxdcViewController: WKScriptMessageHandler { rootController.popToRootViewController(animated: false) } })) + + if let name = dict["name"] as? String { + alert.addAction(UIAlertAction(title: String.localized("menu_share"), style: .default, handler: { [weak self] _ in + guard let self else { return } + if let base64 = dict["base64"] as? String, let data = Data(base64Encoded: base64), let sourceItem = navigationItem.rightBarButtonItem { + let fileURL = FileManager.default.temporaryDirectory.appendingPathComponent(name) + try? FileManager.default.removeItem(at: fileURL) + try? data.write(to: fileURL) + Utils.share(url: fileURL, parentViewController: self, sourceItem: sourceItem) + } + })) + } + alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil)) self.present(alert, animated: true, completion: nil) }