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​
1
import UIKit
2
import WebKit
3
​
4
class WebViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {
5
@IBOutlet weak var webView: WKWebView!
6
​
7
override func loadView() {
8
let webConfiguration = WKWebViewConfiguration()
9
webView = WKWebView(frame: .zero, configuration: webConfiguration)
10
webView.uiDelegate = self
11
webView.navigationDelegate = self
12
view = webView
13
}
14
​
15
override func viewDidLoad() {
16
super.viewDidLoad()
17
let myURL = URL(string: "https://global.transak.com?apiKey=[YOUR_PRODUCTION_API_KEY]&[QUERY_PARAMETERS]")
18
let myRequest = URLRequest(url: myURL!)
19
webView.load(myRequest)
20
}
21
​
22
func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
23
if let serverTrust = challenge.protectionSpace.serverTrust {
24
completionHandler(.useCredential, URLCredential(trust: serverTrust))
25
}
26
}
27
}
Copied!
Copy link