mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Bot previews
This commit is contained in:
@@ -4,6 +4,7 @@ import Display
|
||||
import AsyncDisplayKit
|
||||
import WebKit
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
|
||||
private class WeakPaymentScriptMessageHandler: NSObject, WKScriptMessageHandler {
|
||||
private let f: (WKScriptMessage) -> ()
|
||||
@@ -20,12 +21,14 @@ private class WeakPaymentScriptMessageHandler: NSObject, WKScriptMessageHandler
|
||||
}
|
||||
|
||||
final class BotCheckoutWebInteractionControllerNode: ViewControllerTracingNode, WKNavigationDelegate {
|
||||
private let context: AccountContext
|
||||
private var presentationData: PresentationData
|
||||
private let intent: BotCheckoutWebInteractionControllerIntent
|
||||
|
||||
private var webView: WKWebView?
|
||||
|
||||
init(presentationData: PresentationData, url: String, intent: BotCheckoutWebInteractionControllerIntent) {
|
||||
init(context: AccountContext, presentationData: PresentationData, url: String, intent: BotCheckoutWebInteractionControllerIntent) {
|
||||
self.context = context
|
||||
self.presentationData = presentationData
|
||||
self.intent = intent
|
||||
|
||||
@@ -146,6 +149,14 @@ final class BotCheckoutWebInteractionControllerNode: ViewControllerTracingNode,
|
||||
decisionHandler(.allow)
|
||||
}
|
||||
} else {
|
||||
if let url = navigationAction.request.url, let scheme = url.scheme {
|
||||
let defaultSchemes: [String] = ["http", "https"]
|
||||
if !defaultSchemes.contains(scheme) {
|
||||
decisionHandler(.cancel)
|
||||
self.context.sharedContext.applicationBindings.openUrl(url.absoluteString)
|
||||
return
|
||||
}
|
||||
}
|
||||
decisionHandler(.allow)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user