This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) { | |
guard let url = urlSchemeTask.request.url else { return } | |
guard let queryItem = URLComponents(url: url, resolvingAgainstBaseURL: true)?.queryItems?.first else { return } | |
guard let value = queryItem.value else { return } | |
if queryItem.name == PreviewViewModel.imageQueryName { | |
makeImageResponse(url: url, identifier: value, urlSchemeTask: urlSchemeTask) | |
} | |
if queryItem.name == PreviewViewModel.textQueryName { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import WebKit | |
import Photos | |
import RxSwift | |
class UploadWKSchemeHandler: NSObject, WKURLSchemeHandler { | |
private var imageMime = "image/jpeg" | |
private var textMime = "text/plain" | |
private var disposeBag = DisposeBag() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func configWebView() { | |
guard webView == nil else { return } | |
let config = WKWebViewConfiguration() | |
config.userContentController.add(WebKitLeakAvoider(delegate: self), name: CashfeedWebUtil.JavaScriptMessage.getPost) | |
config.userContentController.add(WebKitLeakAvoider(delegate: self), name: CashfeedWebUtil.JavaScriptMessage.getUserInfo) | |
config.userContentController.add(WebKitLeakAvoider(delegate: self), name: CashfeedWebUtil.JavaScriptMessage.getDeviceInfo) | |
config.setURLSchemeHandler(UploadWKSchemeHandler(), forURLScheme: PreviewViewModel.uploadURLScheme) | |
config.allowsInlineMediaPlayback = true | |
config.mediaTypesRequiringUserActionForPlayback = .audio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private let uploadQueue = DispatchQueue(label: "com.upload.networking", | |
qos: .utility, | |
attributes: .concurrent) | |
//... | |
if Reachability.checkWiFi() { | |
DispatchQueue.main.async { self.appendUploadingView() } | |
self.uploadQueue.async { self.uploadViewModel.inputs.uploadAttachment() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let label = "com.myApp.networking" | |
let queue = DispatchQueue(label: label, attributes: .concurrent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction private func uploadAction() { | |
dismissKeyboard() | |
guard !((titleTextField.text?.isEmpty) ?? true) else { | |
Toast(text: "제목을 입력해주세요 :)").show() | |
return | |
} | |
showPencilUsingAllowPopup(action: { [weak self] in | |
if Reachability.checkWiFi() { | |
//1. |