Transak Docs
Search…
🍎
iOS
You can add the Transak widget to your iOS app using the below code. Make sure to add your API key:
Make sure to add your API key and customise using query parameters​
import UIKit
import WebKit
​
class WebViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {
@IBOutlet weak var webView: WKWebView!
​
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
webView.navigationDelegate = self
view = webView
}
​
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string: "https://global.transak.com?apiKey=[YOUR_PRODUCTION_API_KEY]&[QUERY_PARAMETERS]")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
​
func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
if let serverTrust = challenge.protectionSpace.serverTrust {
completionHandler(.useCredential, URLCredential(trust: serverTrust))
}
}
}
Copy link